var hl = Object.defineProperty;
var Ns = (U) => {
  throw TypeError(U);
};
var dl = (U, y, M) => y in U ? hl(U, y, { enumerable: !0, configurable: !0, writable: !0, value: M }) : U[y] = M;
var tn = (U, y, M) => dl(U, typeof y != "symbol" ? y + "" : y, M), nn = (U, y, M) => y.has(U) || Ns("Cannot " + M);
var Ce = (U, y, M) => (nn(U, y, "read from private field"), M ? M.call(U) : y.get(U)), ot = (U, y, M) => y.has(U) ? Ns("Cannot add the same private member more than once") : y instanceof WeakSet ? y.add(U) : y.set(U, M), ut = (U, y, M, l) => (nn(U, y, "write to private field"), l ? l.call(U, M) : y.set(U, M), M), de = (U, y, M) => (nn(U, y, "access private method"), M);
function _l(U) {
  return U && U.__esModule && Object.prototype.hasOwnProperty.call(U, "default") ? U.default : U;
}
const pl = "JsSIP", vl = "3.10.1", mi = {
  title: pl,
  version: vl
};
var rn, ks;
function Re() {
  if (ks) return rn;
  ks = 1;
  var U = mi;
  return rn = {
    USER_AGENT: "".concat(U.title, " ").concat(U.version),
    // SIP scheme.
    SIP: "sip",
    SIPS: "sips",
    // End and Failure causes.
    causes: {
      // Generic error causes.
      CONNECTION_ERROR: "Connection Error",
      REQUEST_TIMEOUT: "Request Timeout",
      SIP_FAILURE_CODE: "SIP Failure Code",
      INTERNAL_ERROR: "Internal Error",
      // SIP error causes.
      BUSY: "Busy",
      REJECTED: "Rejected",
      REDIRECTED: "Redirected",
      UNAVAILABLE: "Unavailable",
      NOT_FOUND: "Not Found",
      ADDRESS_INCOMPLETE: "Address Incomplete",
      INCOMPATIBLE_SDP: "Incompatible SDP",
      MISSING_SDP: "Missing SDP",
      AUTHENTICATION_ERROR: "Authentication Error",
      // Session error causes.
      BYE: "Terminated",
      WEBRTC_ERROR: "WebRTC Error",
      CANCELED: "Canceled",
      NO_ANSWER: "No Answer",
      EXPIRES: "Expires",
      NO_ACK: "No ACK",
      DIALOG_ERROR: "Dialog Error",
      USER_DENIED_MEDIA_ACCESS: "User Denied Media Access",
      BAD_MEDIA_DESCRIPTION: "Bad Media Description",
      RTP_TIMEOUT: "RTP Timeout"
    },
    SIP_ERROR_CAUSES: {
      REDIRECTED: [300, 301, 302, 305, 380],
      BUSY: [486, 600],
      REJECTED: [403, 603],
      NOT_FOUND: [404, 604],
      UNAVAILABLE: [480, 410, 408, 430],
      ADDRESS_INCOMPLETE: [484, 424],
      INCOMPATIBLE_SDP: [488, 606],
      AUTHENTICATION_ERROR: [401, 407]
    },
    // SIP Methods.
    ACK: "ACK",
    BYE: "BYE",
    CANCEL: "CANCEL",
    INFO: "INFO",
    INVITE: "INVITE",
    MESSAGE: "MESSAGE",
    NOTIFY: "NOTIFY",
    OPTIONS: "OPTIONS",
    REGISTER: "REGISTER",
    REFER: "REFER",
    UPDATE: "UPDATE",
    SUBSCRIBE: "SUBSCRIBE",
    // DTMF transport methods.
    DTMF_TRANSPORT: {
      INFO: "INFO",
      RFC2833: "RFC2833"
    },
    /* SIP Response Reasons
     * DOC: https://www.iana.org/assignments/sip-parameters
     * Copied from https://github.com/versatica/OverSIP/blob/master/lib/oversip/sip/constants.rb#L7
     */
    REASON_PHRASE: {
      100: "Trying",
      180: "Ringing",
      181: "Call Is Being Forwarded",
      182: "Queued",
      183: "Session Progress",
      199: "Early Dialog Terminated",
      // draft-ietf-sipcore-199
      200: "OK",
      202: "Accepted",
      // RFC 3265
      204: "No Notification",
      // RFC 5839
      300: "Multiple Choices",
      301: "Moved Permanently",
      302: "Moved Temporarily",
      305: "Use Proxy",
      380: "Alternative Service",
      400: "Bad Request",
      401: "Unauthorized",
      402: "Payment Required",
      403: "Forbidden",
      404: "Not Found",
      405: "Method Not Allowed",
      406: "Not Acceptable",
      407: "Proxy Authentication Required",
      408: "Request Timeout",
      410: "Gone",
      412: "Conditional Request Failed",
      // RFC 3903
      413: "Request Entity Too Large",
      414: "Request-URI Too Long",
      415: "Unsupported Media Type",
      416: "Unsupported URI Scheme",
      417: "Unknown Resource-Priority",
      // RFC 4412
      420: "Bad Extension",
      421: "Extension Required",
      422: "Session Interval Too Small",
      // RFC 4028
      423: "Interval Too Brief",
      424: "Bad Location Information",
      // RFC 6442
      428: "Use Identity Header",
      // RFC 4474
      429: "Provide Referrer Identity",
      // RFC 3892
      430: "Flow Failed",
      // RFC 5626
      433: "Anonymity Disallowed",
      // RFC 5079
      436: "Bad Identity-Info",
      // RFC 4474
      437: "Unsupported Certificate",
      // RFC 4744
      438: "Invalid Identity Header",
      // RFC 4744
      439: "First Hop Lacks Outbound Support",
      // RFC 5626
      440: "Max-Breadth Exceeded",
      // RFC 5393
      469: "Bad Info Package",
      // draft-ietf-sipcore-info-events
      470: "Consent Needed",
      // RFC 5360
      478: "Unresolvable Destination",
      // Custom code copied from Kamailio.
      480: "Temporarily Unavailable",
      481: "Call/Transaction Does Not Exist",
      482: "Loop Detected",
      483: "Too Many Hops",
      484: "Address Incomplete",
      485: "Ambiguous",
      486: "Busy Here",
      487: "Request Terminated",
      488: "Not Acceptable Here",
      489: "Bad Event",
      // RFC 3265
      491: "Request Pending",
      493: "Undecipherable",
      494: "Security Agreement Required",
      // RFC 3329
      500: "JsSIP Internal Error",
      501: "Not Implemented",
      502: "Bad Gateway",
      503: "Service Unavailable",
      504: "Server Time-out",
      505: "Version Not Supported",
      513: "Message Too Large",
      580: "Precondition Failure",
      // RFC 3312
      600: "Busy Everywhere",
      603: "Decline",
      604: "Does Not Exist Anywhere",
      606: "Not Acceptable"
    },
    ALLOWED_METHODS: "INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY",
    ACCEPTED_BODY_TYPES: "application/sdp, application/dtmf-relay",
    MAX_FORWARDS: 69,
    SESSION_EXPIRES: 90,
    MIN_SESSION_EXPIRES: 60,
    CONNECTION_RECOVERY_MAX_INTERVAL: 30,
    CONNECTION_RECOVERY_MIN_INTERVAL: 2
  }, rn;
}
var sn, Ds;
function Ge() {
  if (Ds) return sn;
  Ds = 1;
  function U(P) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(k) {
      return typeof k;
    } : U = function(k) {
      return k && typeof Symbol == "function" && k.constructor === Symbol && k !== Symbol.prototype ? "symbol" : typeof k;
    }, U(P);
  }
  function y(P, g) {
    if (!(P instanceof g))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(P, g) {
    if (typeof g != "function" && g !== null)
      throw new TypeError("Super expression must either be null or a function");
    P.prototype = Object.create(g && g.prototype, { constructor: { value: P, writable: !0, configurable: !0 } }), g && c(P, g);
  }
  function l(P) {
    var g = E();
    return function() {
      var N = o(P), T;
      if (g) {
        var v = o(this).constructor;
        T = Reflect.construct(N, arguments, v);
      } else
        T = N.apply(this, arguments);
      return X(this, T);
    };
  }
  function X(P, g) {
    return g && (U(g) === "object" || typeof g == "function") ? g : F(P);
  }
  function F(P) {
    if (P === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return P;
  }
  function t(P) {
    var g = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
    return t = function(N) {
      if (N === null || !i(N)) return N;
      if (typeof N != "function")
        throw new TypeError("Super expression must either be null or a function");
      if (typeof g < "u") {
        if (g.has(N)) return g.get(N);
        g.set(N, T);
      }
      function T() {
        return b(N, arguments, o(this).constructor);
      }
      return T.prototype = Object.create(N.prototype, { constructor: { value: T, enumerable: !1, writable: !0, configurable: !0 } }), c(T, N);
    }, t(P);
  }
  function b(P, g, k) {
    return E() ? b = Reflect.construct : b = function(T, v, w) {
      var I = [null];
      I.push.apply(I, v);
      var C = Function.bind.apply(T, I), O = new C();
      return w && c(O, w.prototype), O;
    }, b.apply(null, arguments);
  }
  function E() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function i(P) {
    return Function.toString.call(P).indexOf("[native code]") !== -1;
  }
  function c(P, g) {
    return c = Object.setPrototypeOf || function(N, T) {
      return N.__proto__ = T, N;
    }, c(P, g);
  }
  function o(P) {
    return o = Object.setPrototypeOf ? Object.getPrototypeOf : function(k) {
      return k.__proto__ || Object.getPrototypeOf(k);
    }, o(P);
  }
  var h = /* @__PURE__ */ function(P) {
    M(k, P);
    var g = l(k);
    function k(N, T) {
      var v;
      return y(this, k), v = g.call(this), v.code = 1, v.name = "CONFIGURATION_ERROR", v.parameter = N, v.value = T, v.message = v.value ? "Invalid value ".concat(JSON.stringify(v.value), ' for parameter "').concat(v.parameter, '"') : "Missing parameter: ".concat(v.parameter), v;
    }
    return k;
  }(/* @__PURE__ */ t(Error)), p = /* @__PURE__ */ function(P) {
    M(k, P);
    var g = l(k);
    function k(N) {
      var T;
      return y(this, k), T = g.call(this), T.code = 2, T.name = "INVALID_STATE_ERROR", T.status = N, T.message = "Invalid status: ".concat(N), T;
    }
    return k;
  }(/* @__PURE__ */ t(Error)), W = /* @__PURE__ */ function(P) {
    M(k, P);
    var g = l(k);
    function k(N) {
      var T;
      return y(this, k), T = g.call(this), T.code = 3, T.name = "NOT_SUPPORTED_ERROR", T.message = N, T;
    }
    return k;
  }(/* @__PURE__ */ t(Error)), j = /* @__PURE__ */ function(P) {
    M(k, P);
    var g = l(k);
    function k(N) {
      var T;
      return y(this, k), T = g.call(this), T.code = 4, T.name = "NOT_READY_ERROR", T.message = N, T;
    }
    return k;
  }(/* @__PURE__ */ t(Error));
  return sn = {
    ConfigurationError: h,
    InvalidStateError: p,
    NotSupportedError: W,
    NotReadyError: j
  }, sn;
}
var Ee = {}, ln, Ps;
function Bn() {
  if (Ps) return ln;
  Ps = 1;
  function U(F, t) {
    if (!(F instanceof t))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(F, t) {
    for (var b = 0; b < t.length; b++) {
      var E = t[b];
      E.enumerable = E.enumerable || !1, E.configurable = !0, "value" in E && (E.writable = !0), Object.defineProperty(F, E.key, E);
    }
  }
  function M(F, t, b) {
    return t && y(F.prototype, t), b && y(F, b), F;
  }
  var l = Ve(), X = Ue();
  return ln = /* @__PURE__ */ function() {
    M(F, null, [{
      key: "parse",
      /**
       * Parse the given string and returns a NameAddrHeader instance or undefined if
       * it is an invalid NameAddrHeader.
       */
      value: function(b) {
        if (b = X.parse(b, "Name_Addr_Header"), b !== -1)
          return b;
      }
    }]);
    function F(t, b, E) {
      if (U(this, F), !t || !(t instanceof l))
        throw new TypeError('missing or invalid "uri" parameter');
      this._uri = t, this._parameters = {}, this.display_name = b;
      for (var i in E)
        Object.prototype.hasOwnProperty.call(E, i) && this.setParam(i, E[i]);
    }
    return M(F, [{
      key: "setParam",
      value: function(b, E) {
        b && (this._parameters[b.toLowerCase()] = typeof E > "u" || E === null ? null : E.toString());
      }
    }, {
      key: "getParam",
      value: function(b) {
        if (b)
          return this._parameters[b.toLowerCase()];
      }
    }, {
      key: "hasParam",
      value: function(b) {
        if (b)
          return this._parameters.hasOwnProperty(b.toLowerCase()) && !0 || !1;
      }
    }, {
      key: "deleteParam",
      value: function(b) {
        if (b = b.toLowerCase(), this._parameters.hasOwnProperty(b)) {
          var E = this._parameters[b];
          return delete this._parameters[b], E;
        }
      }
    }, {
      key: "clearParams",
      value: function() {
        this._parameters = {};
      }
    }, {
      key: "clone",
      value: function() {
        return new F(this._uri.clone(), this._display_name, JSON.parse(JSON.stringify(this._parameters)));
      }
    }, {
      key: "_quote",
      value: function(b) {
        return b.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
      }
    }, {
      key: "toString",
      value: function() {
        var b = this._display_name ? '"'.concat(this._quote(this._display_name), '" ') : "";
        b += "<".concat(this._uri.toString(), ">");
        for (var E in this._parameters)
          Object.prototype.hasOwnProperty.call(this._parameters, E) && (b += ";".concat(E), this._parameters[E] !== null && (b += "=".concat(this._parameters[E])));
        return b;
      }
    }, {
      key: "uri",
      get: function() {
        return this._uri;
      }
    }, {
      key: "display_name",
      get: function() {
        return this._display_name;
      },
      set: function(b) {
        this._display_name = b === 0 ? "0" : b;
      }
    }]), F;
  }(), ln;
}
var an, xs;
function Ue() {
  return xs || (xs = 1, an = function() {
    function U(M) {
      return '"' + M.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\x08/g, "\\b").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\f/g, "\\f").replace(/\r/g, "\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) + '"';
    }
    var y = {
      /*
       * Parses the input with a generated parser. If the parsing is successfull,
       * returns a value explicitly or implicitly specified by the grammar from
       * which the parser was generated (see |PEG.buildParser|). If the parsing is
       * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
       */
      parse: function(l, X) {
        var F = {
          CRLF: c,
          DIGIT: o,
          ALPHA: h,
          HEXDIG: p,
          WSP: W,
          OCTET: j,
          DQUOTE: P,
          SP: g,
          HTAB: k,
          alphanum: N,
          reserved: T,
          unreserved: v,
          mark: w,
          escaped: I,
          LWS: C,
          SWS: O,
          HCOLON: K,
          TEXT_UTF8_TRIM: Y,
          TEXT_UTF8char: D,
          UTF8_NONASCII: B,
          UTF8_CONT: d,
          LHEX: _,
          token: R,
          token_nodot: A,
          separators: G,
          word: V,
          STAR: x,
          SLASH: u,
          EQUAL: m,
          LPAREN: L,
          RPAREN: q,
          RAQUOT: $,
          LAQUOT: z,
          COMMA: ee,
          SEMI: Z,
          COLON: re,
          LDQUOT: se,
          RDQUOT: ne,
          comment: he,
          ctext: pe,
          quoted_string: Te,
          quoted_string_clean: ue,
          qdtext: ae,
          quoted_pair: ce,
          SIP_URI_noparams: _e,
          SIP_URI: ve,
          uri_scheme: Se,
          uri_scheme_sips: me,
          uri_scheme_sip: Me,
          userinfo: we,
          user: Qe,
          user_unreserved: Ze,
          password: ye,
          hostport: qe,
          host: je,
          hostname: Dt,
          domainlabel: Pt,
          toplabel: Kn,
          IPv6reference: xt,
          IPv6address: Ut,
          h16: ie,
          ls32: ke,
          IPv4address: et,
          dec_octet: tt,
          port: zn,
          uri_parameters: Yn,
          uri_parameter: Mt,
          transport_param: $n,
          user_param: Jn,
          method_param: Xn,
          ttl_param: Qn,
          maddr_param: Zn,
          lr_param: er,
          other_param: tr,
          pname: nr,
          pvalue: rr,
          paramchar: nt,
          param_unreserved: sr,
          headers: ir,
          header: dt,
          hname: lr,
          hvalue: ar,
          hnv_unreserved: rt,
          Request_Response: Ii,
          Request_Line: or,
          Request_URI: ur,
          absoluteURI: Lt,
          hier_part: fr,
          net_path: cr,
          abs_path: _t,
          opaque_part: hr,
          uric: st,
          uric_no_slash: dr,
          path_segments: _r,
          segment: pt,
          param: Ft,
          pchar: it,
          scheme: pr,
          authority: vr,
          srvr: mr,
          reg_name: gr,
          query: yr,
          SIP_Version: Ht,
          INVITEm: Tr,
          ACKm: Sr,
          OPTIONSm: Cr,
          BYEm: Er,
          CANCELm: Ar,
          REGISTERm: br,
          SUBSCRIBEm: Rr,
          NOTIFYm: wr,
          REFERm: Ir,
          Method: vt,
          Status_Line: Or,
          Status_Code: Nr,
          extension_code: kr,
          Reason_Phrase: Dr,
          Allow_Events: Oi,
          Call_ID: Ni,
          Contact: ki,
          contact_param: mt,
          name_addr: We,
          display_name: gt,
          contact_params: qt,
          c_p_q: Pr,
          c_p_expires: xr,
          delta_seconds: Ke,
          qvalue: Ur,
          generic_param: Ae,
          gen_value: Mr,
          Content_Disposition: Di,
          disp_type: Lr,
          disp_param: jt,
          handling_param: Fr,
          Content_Encoding: Pi,
          Content_Length: xi,
          Content_Type: Ui,
          media_type: Hr,
          m_type: qr,
          discrete_type: jr,
          composite_type: Gr,
          extension_token: yt,
          x_token: Vr,
          m_subtype: Br,
          m_parameter: Gt,
          m_value: Wr,
          CSeq: Mi,
          CSeq_value: Kr,
          Expires: Li,
          Event: Fi,
          event_type: lt,
          From: Hi,
          from_param: Vt,
          tag_param: Bt,
          Max_Forwards: qi,
          Min_Expires: ji,
          Name_Addr_Header: Gi,
          Proxy_Authenticate: Vi,
          challenge: Wt,
          other_challenge: zr,
          auth_param: at,
          digest_cln: Tt,
          realm: Yr,
          realm_value: $r,
          domain: Jr,
          URI: St,
          nonce: Xr,
          nonce_value: Qr,
          opaque: Zr,
          stale: es,
          algorithm: ts,
          qop_options: ns,
          qop_value: Ct,
          Proxy_Require: Bi,
          Record_Route: Wi,
          rec_route: Et,
          Reason: Ki,
          reason_param: Kt,
          reason_cause: rs,
          Require: zi,
          Route: Yi,
          route_param: At,
          Subscription_State: $i,
          substate_value: ss,
          subexp_params: zt,
          event_reason_value: is,
          Subject: Ji,
          Supported: Xi,
          To: Qi,
          to_param: Yt,
          Via: Zi,
          via_param: bt,
          via_params: $t,
          via_ttl: ls,
          via_maddr: as,
          via_received: os,
          via_branch: us,
          response_port: fs,
          rport: cs,
          sent_protocol: hs,
          protocol_name: ds,
          transport: _s,
          sent_by: ps,
          via_host: vs,
          via_port: ms,
          ttl: Jt,
          WWW_Authenticate: el,
          Session_Expires: tl,
          s_e_expires: gs,
          s_e_params: Xt,
          s_e_refresher: ys,
          extension_header: nl,
          header_value: Ts,
          message_body: rl,
          uuid_URI: sl,
          uuid: Ss,
          hex4: Le,
          hex8: Cs,
          hex12: Es,
          Refer_To: il,
          Replaces: ll,
          call_id: As,
          replaces_param: Qt,
          to_tag: bs,
          from_tag: Rs,
          early_flag: ws
        };
        if (X !== void 0) {
          if (F[X] === void 0)
            throw new Error("Invalid rule name: " + U(X) + ".");
        } else
          X = "CRLF";
        var t = 0, b = 0, E = [];
        function i(e) {
          t < b || (t > b && (b = t, E = []), E.push(e));
        }
        function c() {
          var e;
          return l.substr(t, 2) === `\r
` ? (e = `\r
`, t += 2) : (e = null, i('"\\r\\n"')), e;
        }
        function o() {
          var e;
          return /^[0-9]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[0-9]")), e;
        }
        function h() {
          var e;
          return /^[a-zA-Z]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[a-zA-Z]")), e;
        }
        function p() {
          var e;
          return /^[0-9a-fA-F]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[0-9a-fA-F]")), e;
        }
        function W() {
          var e;
          return e = g(), e === null && (e = k()), e;
        }
        function j() {
          var e;
          return /^[\0-\xFF]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[\\0-\\xFF]")), e;
        }
        function P() {
          var e;
          return /^["]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i('["]')), e;
        }
        function g() {
          var e;
          return l.charCodeAt(t) === 32 ? (e = " ", t++) : (e = null, i('" "')), e;
        }
        function k() {
          var e;
          return l.charCodeAt(t) === 9 ? (e = "	", t++) : (e = null, i('"\\t"')), e;
        }
        function N() {
          var e;
          return /^[a-zA-Z0-9]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[a-zA-Z0-9]")), e;
        }
        function T() {
          var e;
          return l.charCodeAt(t) === 59 ? (e = ";", t++) : (e = null, i('";"')), e === null && (l.charCodeAt(t) === 47 ? (e = "/", t++) : (e = null, i('"/"')), e === null && (l.charCodeAt(t) === 63 ? (e = "?", t++) : (e = null, i('"?"')), e === null && (l.charCodeAt(t) === 58 ? (e = ":", t++) : (e = null, i('":"')), e === null && (l.charCodeAt(t) === 64 ? (e = "@", t++) : (e = null, i('"@"')), e === null && (l.charCodeAt(t) === 38 ? (e = "&", t++) : (e = null, i('"&"')), e === null && (l.charCodeAt(t) === 61 ? (e = "=", t++) : (e = null, i('"="')), e === null && (l.charCodeAt(t) === 43 ? (e = "+", t++) : (e = null, i('"+"')), e === null && (l.charCodeAt(t) === 36 ? (e = "$", t++) : (e = null, i('"$"')), e === null && (l.charCodeAt(t) === 44 ? (e = ",", t++) : (e = null, i('","'))))))))))), e;
        }
        function v() {
          var e;
          return e = N(), e === null && (e = w()), e;
        }
        function w() {
          var e;
          return l.charCodeAt(t) === 45 ? (e = "-", t++) : (e = null, i('"-"')), e === null && (l.charCodeAt(t) === 95 ? (e = "_", t++) : (e = null, i('"_"')), e === null && (l.charCodeAt(t) === 46 ? (e = ".", t++) : (e = null, i('"."')), e === null && (l.charCodeAt(t) === 33 ? (e = "!", t++) : (e = null, i('"!"')), e === null && (l.charCodeAt(t) === 126 ? (e = "~", t++) : (e = null, i('"~"')), e === null && (l.charCodeAt(t) === 42 ? (e = "*", t++) : (e = null, i('"*"')), e === null && (l.charCodeAt(t) === 39 ? (e = "'", t++) : (e = null, i(`"'"`)), e === null && (l.charCodeAt(t) === 40 ? (e = "(", t++) : (e = null, i('"("')), e === null && (l.charCodeAt(t) === 41 ? (e = ")", t++) : (e = null, i('")"')))))))))), e;
        }
        function I() {
          var e, n, r, s, a;
          return s = t, a = t, l.charCodeAt(t) === 37 ? (e = "%", t++) : (e = null, i('"%"')), e !== null ? (n = p(), n !== null ? (r = p(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            return S.join("");
          }(s, e)), e === null && (t = s), e;
        }
        function C() {
          var e, n, r, s, a, f;
          for (s = t, a = t, f = t, e = [], n = W(); n !== null; )
            e.push(n), n = W();
          if (e !== null ? (n = c(), n !== null ? e = [e, n] : (e = null, t = f)) : (e = null, t = f), e = e !== null ? e : "", e !== null) {
            if (r = W(), r !== null)
              for (n = []; r !== null; )
                n.push(r), r = W();
            else
              n = null;
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e !== null && (e = /* @__PURE__ */ function(S) {
            return " ";
          }()), e === null && (t = s), e;
        }
        function O() {
          var e;
          return e = C(), e = e !== null ? e : "", e;
        }
        function K() {
          var e, n, r, s, a;
          for (s = t, a = t, e = [], n = g(), n === null && (n = k()); n !== null; )
            e.push(n), n = g(), n === null && (n = k());
          return e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return ":";
          }()), e === null && (t = s), e;
        }
        function Y() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, n = D(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = D();
          else
            e = null;
          if (e !== null) {
            for (n = [], S = t, r = [], s = C(); s !== null; )
              r.push(s), s = C();
            for (r !== null ? (s = D(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; ) {
              for (n.push(r), S = t, r = [], s = C(); s !== null; )
                r.push(s), s = C();
              r !== null ? (s = D(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            }
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            return l.substring(t, J);
          }(a)), e === null && (t = a), e;
        }
        function D() {
          var e;
          return /^[!-~]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[!-~]")), e === null && (e = B()), e;
        }
        function B() {
          var e;
          return /^[\x80-\uFFFF]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[\\x80-\\uFFFF]")), e;
        }
        function d() {
          var e;
          return /^[\x80-\xBF]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[\\x80-\\xBF]")), e;
        }
        function _() {
          var e;
          return e = o(), e === null && (/^[a-f]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[a-f]"))), e;
        }
        function R() {
          var e, n, r;
          if (r = t, n = N(), n === null && (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n === null && (l.charCodeAt(t) === 46 ? (n = ".", t++) : (n = null, i('"."')), n === null && (l.charCodeAt(t) === 33 ? (n = "!", t++) : (n = null, i('"!"')), n === null && (l.charCodeAt(t) === 37 ? (n = "%", t++) : (n = null, i('"%"')), n === null && (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n === null && (l.charCodeAt(t) === 95 ? (n = "_", t++) : (n = null, i('"_"')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 96 ? (n = "`", t++) : (n = null, i('"`"')), n === null && (l.charCodeAt(t) === 39 ? (n = "'", t++) : (n = null, i(`"'"`)), n === null && (l.charCodeAt(t) === 126 ? (n = "~", t++) : (n = null, i('"~"')))))))))))), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = N(), n === null && (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n === null && (l.charCodeAt(t) === 46 ? (n = ".", t++) : (n = null, i('"."')), n === null && (l.charCodeAt(t) === 33 ? (n = "!", t++) : (n = null, i('"!"')), n === null && (l.charCodeAt(t) === 37 ? (n = "%", t++) : (n = null, i('"%"')), n === null && (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n === null && (l.charCodeAt(t) === 95 ? (n = "_", t++) : (n = null, i('"_"')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 96 ? (n = "`", t++) : (n = null, i('"`"')), n === null && (l.charCodeAt(t) === 39 ? (n = "'", t++) : (n = null, i(`"'"`)), n === null && (l.charCodeAt(t) === 126 ? (n = "~", t++) : (n = null, i('"~"'))))))))))));
          else
            e = null;
          return e !== null && (e = function(s) {
            return l.substring(t, s);
          }(r)), e === null && (t = r), e;
        }
        function A() {
          var e, n, r;
          if (r = t, n = N(), n === null && (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n === null && (l.charCodeAt(t) === 33 ? (n = "!", t++) : (n = null, i('"!"')), n === null && (l.charCodeAt(t) === 37 ? (n = "%", t++) : (n = null, i('"%"')), n === null && (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n === null && (l.charCodeAt(t) === 95 ? (n = "_", t++) : (n = null, i('"_"')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 96 ? (n = "`", t++) : (n = null, i('"`"')), n === null && (l.charCodeAt(t) === 39 ? (n = "'", t++) : (n = null, i(`"'"`)), n === null && (l.charCodeAt(t) === 126 ? (n = "~", t++) : (n = null, i('"~"'))))))))))), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = N(), n === null && (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n === null && (l.charCodeAt(t) === 33 ? (n = "!", t++) : (n = null, i('"!"')), n === null && (l.charCodeAt(t) === 37 ? (n = "%", t++) : (n = null, i('"%"')), n === null && (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n === null && (l.charCodeAt(t) === 95 ? (n = "_", t++) : (n = null, i('"_"')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 96 ? (n = "`", t++) : (n = null, i('"`"')), n === null && (l.charCodeAt(t) === 39 ? (n = "'", t++) : (n = null, i(`"'"`)), n === null && (l.charCodeAt(t) === 126 ? (n = "~", t++) : (n = null, i('"~"')))))))))));
          else
            e = null;
          return e !== null && (e = function(s) {
            return l.substring(t, s);
          }(r)), e === null && (t = r), e;
        }
        function G() {
          var e;
          return l.charCodeAt(t) === 40 ? (e = "(", t++) : (e = null, i('"("')), e === null && (l.charCodeAt(t) === 41 ? (e = ")", t++) : (e = null, i('")"')), e === null && (l.charCodeAt(t) === 60 ? (e = "<", t++) : (e = null, i('"<"')), e === null && (l.charCodeAt(t) === 62 ? (e = ">", t++) : (e = null, i('">"')), e === null && (l.charCodeAt(t) === 64 ? (e = "@", t++) : (e = null, i('"@"')), e === null && (l.charCodeAt(t) === 44 ? (e = ",", t++) : (e = null, i('","')), e === null && (l.charCodeAt(t) === 59 ? (e = ";", t++) : (e = null, i('";"')), e === null && (l.charCodeAt(t) === 58 ? (e = ":", t++) : (e = null, i('":"')), e === null && (l.charCodeAt(t) === 92 ? (e = "\\", t++) : (e = null, i('"\\\\"')), e === null && (e = P(), e === null && (l.charCodeAt(t) === 47 ? (e = "/", t++) : (e = null, i('"/"')), e === null && (l.charCodeAt(t) === 91 ? (e = "[", t++) : (e = null, i('"["')), e === null && (l.charCodeAt(t) === 93 ? (e = "]", t++) : (e = null, i('"]"')), e === null && (l.charCodeAt(t) === 63 ? (e = "?", t++) : (e = null, i('"?"')), e === null && (l.charCodeAt(t) === 61 ? (e = "=", t++) : (e = null, i('"="')), e === null && (l.charCodeAt(t) === 123 ? (e = "{", t++) : (e = null, i('"{"')), e === null && (l.charCodeAt(t) === 125 ? (e = "}", t++) : (e = null, i('"}"')), e === null && (e = g(), e === null && (e = k())))))))))))))))))), e;
        }
        function V() {
          var e, n, r;
          if (r = t, n = N(), n === null && (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n === null && (l.charCodeAt(t) === 46 ? (n = ".", t++) : (n = null, i('"."')), n === null && (l.charCodeAt(t) === 33 ? (n = "!", t++) : (n = null, i('"!"')), n === null && (l.charCodeAt(t) === 37 ? (n = "%", t++) : (n = null, i('"%"')), n === null && (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n === null && (l.charCodeAt(t) === 95 ? (n = "_", t++) : (n = null, i('"_"')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 96 ? (n = "`", t++) : (n = null, i('"`"')), n === null && (l.charCodeAt(t) === 39 ? (n = "'", t++) : (n = null, i(`"'"`)), n === null && (l.charCodeAt(t) === 126 ? (n = "~", t++) : (n = null, i('"~"')), n === null && (l.charCodeAt(t) === 40 ? (n = "(", t++) : (n = null, i('"("')), n === null && (l.charCodeAt(t) === 41 ? (n = ")", t++) : (n = null, i('")"')), n === null && (l.charCodeAt(t) === 60 ? (n = "<", t++) : (n = null, i('"<"')), n === null && (l.charCodeAt(t) === 62 ? (n = ">", t++) : (n = null, i('">"')), n === null && (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n === null && (l.charCodeAt(t) === 92 ? (n = "\\", t++) : (n = null, i('"\\\\"')), n === null && (n = P(), n === null && (l.charCodeAt(t) === 47 ? (n = "/", t++) : (n = null, i('"/"')), n === null && (l.charCodeAt(t) === 91 ? (n = "[", t++) : (n = null, i('"["')), n === null && (l.charCodeAt(t) === 93 ? (n = "]", t++) : (n = null, i('"]"')), n === null && (l.charCodeAt(t) === 63 ? (n = "?", t++) : (n = null, i('"?"')), n === null && (l.charCodeAt(t) === 123 ? (n = "{", t++) : (n = null, i('"{"')), n === null && (l.charCodeAt(t) === 125 ? (n = "}", t++) : (n = null, i('"}"'))))))))))))))))))))))))), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = N(), n === null && (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n === null && (l.charCodeAt(t) === 46 ? (n = ".", t++) : (n = null, i('"."')), n === null && (l.charCodeAt(t) === 33 ? (n = "!", t++) : (n = null, i('"!"')), n === null && (l.charCodeAt(t) === 37 ? (n = "%", t++) : (n = null, i('"%"')), n === null && (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n === null && (l.charCodeAt(t) === 95 ? (n = "_", t++) : (n = null, i('"_"')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 96 ? (n = "`", t++) : (n = null, i('"`"')), n === null && (l.charCodeAt(t) === 39 ? (n = "'", t++) : (n = null, i(`"'"`)), n === null && (l.charCodeAt(t) === 126 ? (n = "~", t++) : (n = null, i('"~"')), n === null && (l.charCodeAt(t) === 40 ? (n = "(", t++) : (n = null, i('"("')), n === null && (l.charCodeAt(t) === 41 ? (n = ")", t++) : (n = null, i('")"')), n === null && (l.charCodeAt(t) === 60 ? (n = "<", t++) : (n = null, i('"<"')), n === null && (l.charCodeAt(t) === 62 ? (n = ">", t++) : (n = null, i('">"')), n === null && (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n === null && (l.charCodeAt(t) === 92 ? (n = "\\", t++) : (n = null, i('"\\\\"')), n === null && (n = P(), n === null && (l.charCodeAt(t) === 47 ? (n = "/", t++) : (n = null, i('"/"')), n === null && (l.charCodeAt(t) === 91 ? (n = "[", t++) : (n = null, i('"["')), n === null && (l.charCodeAt(t) === 93 ? (n = "]", t++) : (n = null, i('"]"')), n === null && (l.charCodeAt(t) === 63 ? (n = "?", t++) : (n = null, i('"?"')), n === null && (l.charCodeAt(t) === 123 ? (n = "{", t++) : (n = null, i('"{"')), n === null && (l.charCodeAt(t) === 125 ? (n = "}", t++) : (n = null, i('"}"')))))))))))))))))))))))));
          else
            e = null;
          return e !== null && (e = function(s) {
            return l.substring(t, s);
          }(r)), e === null && (t = r), e;
        }
        function x() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 42 ? (n = "*", t++) : (n = null, i('"*"')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return "*";
          }()), e === null && (t = s), e;
        }
        function u() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 47 ? (n = "/", t++) : (n = null, i('"/"')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return "/";
          }()), e === null && (t = s), e;
        }
        function m() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return "=";
          }()), e === null && (t = s), e;
        }
        function L() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 40 ? (n = "(", t++) : (n = null, i('"("')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return "(";
          }()), e === null && (t = s), e;
        }
        function q() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 41 ? (n = ")", t++) : (n = null, i('")"')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return ")";
          }()), e === null && (t = s), e;
        }
        function $() {
          var e, n, r, s;
          return r = t, s = t, l.charCodeAt(t) === 62 ? (e = ">", t++) : (e = null, i('">"')), e !== null ? (n = O(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = /* @__PURE__ */ function(a) {
            return ">";
          }()), e === null && (t = r), e;
        }
        function z() {
          var e, n, r, s;
          return r = t, s = t, e = O(), e !== null ? (l.charCodeAt(t) === 60 ? (n = "<", t++) : (n = null, i('"<"')), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = /* @__PURE__ */ function(a) {
            return "<";
          }()), e === null && (t = r), e;
        }
        function ee() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 44 ? (n = ",", t++) : (n = null, i('","')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return ",";
          }()), e === null && (t = s), e;
        }
        function Z() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 59 ? (n = ";", t++) : (n = null, i('";"')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return ";";
          }()), e === null && (t = s), e;
        }
        function re() {
          var e, n, r, s, a;
          return s = t, a = t, e = O(), e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = O(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = /* @__PURE__ */ function(f) {
            return ":";
          }()), e === null && (t = s), e;
        }
        function se() {
          var e, n, r, s;
          return r = t, s = t, e = O(), e !== null ? (n = P(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = /* @__PURE__ */ function(a) {
            return '"';
          }()), e === null && (t = r), e;
        }
        function ne() {
          var e, n, r, s;
          return r = t, s = t, e = P(), e !== null ? (n = O(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = /* @__PURE__ */ function(a) {
            return '"';
          }()), e === null && (t = r), e;
        }
        function he() {
          var e, n, r, s;
          if (s = t, e = L(), e !== null) {
            for (n = [], r = pe(), r === null && (r = ce(), r === null && (r = he())); r !== null; )
              n.push(r), r = pe(), r === null && (r = ce(), r === null && (r = he()));
            n !== null ? (r = q(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s);
          } else
            e = null, t = s;
          return e;
        }
        function pe() {
          var e;
          return /^[!-']/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[!-']")), e === null && (/^[*-[]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[*-[]")), e === null && (/^[\]-~]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[\\]-~]")), e === null && (e = B(), e === null && (e = C())))), e;
        }
        function Te() {
          var e, n, r, s, a, f;
          if (a = t, f = t, e = O(), e !== null)
            if (n = P(), n !== null) {
              for (r = [], s = ae(), s === null && (s = ce()); s !== null; )
                r.push(s), s = ae(), s === null && (s = ce());
              r !== null ? (s = P(), s !== null ? e = [e, n, r, s] : (e = null, t = f)) : (e = null, t = f);
            } else
              e = null, t = f;
          else
            e = null, t = f;
          return e !== null && (e = function(S) {
            return l.substring(t, S);
          }(a)), e === null && (t = a), e;
        }
        function ue() {
          var e, n, r, s, a, f;
          if (a = t, f = t, e = O(), e !== null)
            if (n = P(), n !== null) {
              for (r = [], s = ae(), s === null && (s = ce()); s !== null; )
                r.push(s), s = ae(), s === null && (s = ce());
              r !== null ? (s = P(), s !== null ? e = [e, n, r, s] : (e = null, t = f)) : (e = null, t = f);
            } else
              e = null, t = f;
          else
            e = null, t = f;
          return e !== null && (e = function(S) {
            var J = l.substring(t, S).trim();
            return J.substring(1, J.length - 1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g, "$1");
          }(a)), e === null && (t = a), e;
        }
        function ae() {
          var e;
          return e = C(), e === null && (l.charCodeAt(t) === 33 ? (e = "!", t++) : (e = null, i('"!"')), e === null && (/^[#-[]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[#-[]")), e === null && (/^[\]-~]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[\\]-~]")), e === null && (e = B())))), e;
        }
        function ce() {
          var e, n, r;
          return r = t, l.charCodeAt(t) === 92 ? (e = "\\", t++) : (e = null, i('"\\\\"')), e !== null ? (/^[\0-\t]/.test(l.charAt(t)) ? (n = l.charAt(t), t++) : (n = null, i("[\\0-\\t]")), n === null && (/^[\x0B-\f]/.test(l.charAt(t)) ? (n = l.charAt(t), t++) : (n = null, i("[\\x0B-\\f]")), n === null && (/^[\x0E-]/.test(l.charAt(t)) ? (n = l.charAt(t), t++) : (n = null, i("[\\x0E-]")))), n !== null ? e = [e, n] : (e = null, t = r)) : (e = null, t = r), e;
        }
        function _e() {
          var e, n, r, s, a, f;
          return a = t, f = t, e = Se(), e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = we(), r = r !== null ? r : "", r !== null ? (s = qe(), s !== null ? e = [e, n, r, s] : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f), e !== null && (e = function(S) {
            try {
              H.uri = new Is(H.scheme, H.user, H.host, H.port), delete H.scheme, delete H.user, delete H.host, delete H.host_type, delete H.port;
            } catch {
              H = -1;
            }
          }()), e === null && (t = a), e;
        }
        function ve() {
          var e, n, r, s, a, f, S, J;
          return S = t, J = t, e = Se(), e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = we(), r = r !== null ? r : "", r !== null ? (s = qe(), s !== null ? (a = Yn(), a !== null ? (f = ir(), f = f !== null ? f : "", f !== null ? e = [e, n, r, s, a, f] : (e = null, t = J)) : (e = null, t = J)) : (e = null, t = J)) : (e = null, t = J)) : (e = null, t = J)) : (e = null, t = J), e !== null && (e = function(te) {
            try {
              H.uri = new Is(H.scheme, H.user, H.host, H.port, H.uri_params, H.uri_headers), delete H.scheme, delete H.user, delete H.host, delete H.host_type, delete H.port, delete H.uri_params, X === "SIP_URI" && (H = H.uri);
            } catch {
              H = -1;
            }
          }()), e === null && (t = S), e;
        }
        function Se() {
          var e;
          return e = me(), e === null && (e = Me()), e;
        }
        function me() {
          var e, n;
          return n = t, l.substr(t, 4).toLowerCase() === "sips" ? (e = l.substr(t, 4), t += 4) : (e = null, i('"sips"')), e !== null && (e = function(r, s) {
            H.scheme = s.toLowerCase();
          }(n, e)), e === null && (t = n), e;
        }
        function Me() {
          var e, n;
          return n = t, l.substr(t, 3).toLowerCase() === "sip" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"sip"')), e !== null && (e = function(r, s) {
            H.scheme = s.toLowerCase();
          }(n, e)), e === null && (t = n), e;
        }
        function we() {
          var e, n, r, s, a, f;
          return s = t, a = t, e = Qe(), e !== null ? (f = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ye(), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f), n = n !== null ? n : "", n !== null ? (l.charCodeAt(t) === 64 ? (r = "@", t++) : (r = null, i('"@"')), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S) {
            H.user = decodeURIComponent(l.substring(t - 1, S));
          }(s)), e === null && (t = s), e;
        }
        function Qe() {
          var e, n;
          if (n = v(), n === null && (n = I(), n === null && (n = Ze())), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = v(), n === null && (n = I(), n === null && (n = Ze()));
          else
            e = null;
          return e;
        }
        function Ze() {
          var e;
          return l.charCodeAt(t) === 38 ? (e = "&", t++) : (e = null, i('"&"')), e === null && (l.charCodeAt(t) === 61 ? (e = "=", t++) : (e = null, i('"="')), e === null && (l.charCodeAt(t) === 43 ? (e = "+", t++) : (e = null, i('"+"')), e === null && (l.charCodeAt(t) === 36 ? (e = "$", t++) : (e = null, i('"$"')), e === null && (l.charCodeAt(t) === 44 ? (e = ",", t++) : (e = null, i('","')), e === null && (l.charCodeAt(t) === 59 ? (e = ";", t++) : (e = null, i('";"')), e === null && (l.charCodeAt(t) === 63 ? (e = "?", t++) : (e = null, i('"?"')), e === null && (l.charCodeAt(t) === 47 ? (e = "/", t++) : (e = null, i('"/"'))))))))), e;
        }
        function ye() {
          var e, n, r;
          for (r = t, e = [], n = v(), n === null && (n = I(), n === null && (l.charCodeAt(t) === 38 ? (n = "&", t++) : (n = null, i('"&"')), n === null && (l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 36 ? (n = "$", t++) : (n = null, i('"$"')), n === null && (l.charCodeAt(t) === 44 ? (n = ",", t++) : (n = null, i('","')))))))); n !== null; )
            e.push(n), n = v(), n === null && (n = I(), n === null && (l.charCodeAt(t) === 38 ? (n = "&", t++) : (n = null, i('"&"')), n === null && (l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')), n === null && (l.charCodeAt(t) === 36 ? (n = "$", t++) : (n = null, i('"$"')), n === null && (l.charCodeAt(t) === 44 ? (n = ",", t++) : (n = null, i('","'))))))));
          return e !== null && (e = function(s) {
            H.password = l.substring(t, s);
          }(r)), e === null && (t = r), e;
        }
        function qe() {
          var e, n, r, s, a;
          return s = t, e = je(), e !== null ? (a = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = zn(), r !== null ? n = [n, r] : (n = null, t = a)) : (n = null, t = a), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e;
        }
        function je() {
          var e, n;
          return n = t, e = Dt(), e === null && (e = et(), e === null && (e = xt())), e !== null && (e = function(r) {
            return H.host = l.substring(t, r).toLowerCase(), H.host;
          }(n)), e === null && (t = n), e;
        }
        function Dt() {
          var e, n, r, s, a, f;
          for (s = t, a = t, e = [], f = t, n = Pt(), n !== null ? (l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."')), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f); n !== null; )
            e.push(n), f = t, n = Pt(), n !== null ? (l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."')), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f);
          return e !== null ? (n = Kn(), n !== null ? (l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."')), r = r !== null ? r : "", r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S) {
            return H.host_type = "domain", l.substring(t, S);
          }(s)), e === null && (t = s), e;
        }
        function Pt() {
          var e, n, r, s;
          if (s = t, e = N(), e !== null) {
            for (n = [], r = N(), r === null && (l.charCodeAt(t) === 45 ? (r = "-", t++) : (r = null, i('"-"')), r === null && (l.charCodeAt(t) === 95 ? (r = "_", t++) : (r = null, i('"_"')))); r !== null; )
              n.push(r), r = N(), r === null && (l.charCodeAt(t) === 45 ? (r = "-", t++) : (r = null, i('"-"')), r === null && (l.charCodeAt(t) === 95 ? (r = "_", t++) : (r = null, i('"_"'))));
            n !== null ? e = [e, n] : (e = null, t = s);
          } else
            e = null, t = s;
          return e;
        }
        function Kn() {
          var e, n, r, s;
          if (s = t, e = h(), e !== null) {
            for (n = [], r = N(), r === null && (l.charCodeAt(t) === 45 ? (r = "-", t++) : (r = null, i('"-"')), r === null && (l.charCodeAt(t) === 95 ? (r = "_", t++) : (r = null, i('"_"')))); r !== null; )
              n.push(r), r = N(), r === null && (l.charCodeAt(t) === 45 ? (r = "-", t++) : (r = null, i('"-"')), r === null && (l.charCodeAt(t) === 95 ? (r = "_", t++) : (r = null, i('"_"'))));
            n !== null ? e = [e, n] : (e = null, t = s);
          } else
            e = null, t = s;
          return e;
        }
        function xt() {
          var e, n, r, s, a;
          return s = t, a = t, l.charCodeAt(t) === 91 ? (e = "[", t++) : (e = null, i('"["')), e !== null ? (n = Ut(), n !== null ? (l.charCodeAt(t) === 93 ? (r = "]", t++) : (r = null, i('"]"')), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f) {
            return H.host_type = "IPv6", l.substring(t, f);
          }(s)), e === null && (t = s), e;
        }
        function Ut() {
          var e, n, r, s, a, f, S, J, te, fe, ge, Pe, Rt, en, Q, le;
          return en = t, Q = t, e = ie(), e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? (l.charCodeAt(t) === 58 ? (s = ":", t++) : (s = null, i('":"')), s !== null ? (a = ie(), a !== null ? (l.charCodeAt(t) === 58 ? (f = ":", t++) : (f = null, i('":"')), f !== null ? (S = ie(), S !== null ? (l.charCodeAt(t) === 58 ? (J = ":", t++) : (J = null, i('":"')), J !== null ? (te = ie(), te !== null ? (l.charCodeAt(t) === 58 ? (fe = ":", t++) : (fe = null, i('":"')), fe !== null ? (ge = ie(), ge !== null ? (l.charCodeAt(t) === 58 ? (Pe = ":", t++) : (Pe = null, i('":"')), Pe !== null ? (Rt = ke(), Rt !== null ? e = [e, n, r, s, a, f, S, J, te, fe, ge, Pe, Rt] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ie(), n !== null ? (l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? (l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? (l.charCodeAt(t) === 58 ? (S = ":", t++) : (S = null, i('":"')), S !== null ? (J = ie(), J !== null ? (l.charCodeAt(t) === 58 ? (te = ":", t++) : (te = null, i('":"')), te !== null ? (fe = ie(), fe !== null ? (l.charCodeAt(t) === 58 ? (ge = ":", t++) : (ge = null, i('":"')), ge !== null ? (Pe = ke(), Pe !== null ? e = [e, n, r, s, a, f, S, J, te, fe, ge, Pe] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ie(), n !== null ? (l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? (l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? (l.charCodeAt(t) === 58 ? (S = ":", t++) : (S = null, i('":"')), S !== null ? (J = ie(), J !== null ? (l.charCodeAt(t) === 58 ? (te = ":", t++) : (te = null, i('":"')), te !== null ? (fe = ke(), fe !== null ? e = [e, n, r, s, a, f, S, J, te, fe] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ie(), n !== null ? (l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? (l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? (l.charCodeAt(t) === 58 ? (S = ":", t++) : (S = null, i('":"')), S !== null ? (J = ke(), J !== null ? e = [e, n, r, s, a, f, S, J] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ie(), n !== null ? (l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? (l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ke(), f !== null ? e = [e, n, r, s, a, f] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ie(), n !== null ? (l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ke(), s !== null ? e = [e, n, r, s] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ke(), n !== null ? e = [e, n] : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, l.substr(t, 2) === "::" ? (e = "::", t += 2) : (e = null, i('"::"')), e !== null ? (n = ie(), n !== null ? e = [e, n] : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (l.substr(t, 2) === "::" ? (n = "::", t += 2) : (n = null, i('"::"')), n !== null ? (r = ie(), r !== null ? (l.charCodeAt(t) === 58 ? (s = ":", t++) : (s = null, i('":"')), s !== null ? (a = ie(), a !== null ? (l.charCodeAt(t) === 58 ? (f = ":", t++) : (f = null, i('":"')), f !== null ? (S = ie(), S !== null ? (l.charCodeAt(t) === 58 ? (J = ":", t++) : (J = null, i('":"')), J !== null ? (te = ie(), te !== null ? (l.charCodeAt(t) === 58 ? (fe = ":", t++) : (fe = null, i('":"')), fe !== null ? (ge = ke(), ge !== null ? e = [e, n, r, s, a, f, S, J, te, fe, ge] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (le = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? n = [n, r] : (n = null, t = le)) : (n = null, t = le), n = n !== null ? n : "", n !== null ? (l.substr(t, 2) === "::" ? (r = "::", t += 2) : (r = null, i('"::"')), r !== null ? (s = ie(), s !== null ? (l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? (l.charCodeAt(t) === 58 ? (S = ":", t++) : (S = null, i('":"')), S !== null ? (J = ie(), J !== null ? (l.charCodeAt(t) === 58 ? (te = ":", t++) : (te = null, i('":"')), te !== null ? (fe = ke(), fe !== null ? e = [e, n, r, s, a, f, S, J, te, fe] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (le = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? n = [n, r] : (n = null, t = le)) : (n = null, t = le), n = n !== null ? n : "", n !== null ? (le = t, l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? r = [r, s] : (r = null, t = le)) : (r = null, t = le), r = r !== null ? r : "", r !== null ? (l.substr(t, 2) === "::" ? (s = "::", t += 2) : (s = null, i('"::"')), s !== null ? (a = ie(), a !== null ? (l.charCodeAt(t) === 58 ? (f = ":", t++) : (f = null, i('":"')), f !== null ? (S = ie(), S !== null ? (l.charCodeAt(t) === 58 ? (J = ":", t++) : (J = null, i('":"')), J !== null ? (te = ke(), te !== null ? e = [e, n, r, s, a, f, S, J, te] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (le = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? n = [n, r] : (n = null, t = le)) : (n = null, t = le), n = n !== null ? n : "", n !== null ? (le = t, l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? r = [r, s] : (r = null, t = le)) : (r = null, t = le), r = r !== null ? r : "", r !== null ? (le = t, l.charCodeAt(t) === 58 ? (s = ":", t++) : (s = null, i('":"')), s !== null ? (a = ie(), a !== null ? s = [s, a] : (s = null, t = le)) : (s = null, t = le), s = s !== null ? s : "", s !== null ? (l.substr(t, 2) === "::" ? (a = "::", t += 2) : (a = null, i('"::"')), a !== null ? (f = ie(), f !== null ? (l.charCodeAt(t) === 58 ? (S = ":", t++) : (S = null, i('":"')), S !== null ? (J = ke(), J !== null ? e = [e, n, r, s, a, f, S, J] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (le = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? n = [n, r] : (n = null, t = le)) : (n = null, t = le), n = n !== null ? n : "", n !== null ? (le = t, l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? r = [r, s] : (r = null, t = le)) : (r = null, t = le), r = r !== null ? r : "", r !== null ? (le = t, l.charCodeAt(t) === 58 ? (s = ":", t++) : (s = null, i('":"')), s !== null ? (a = ie(), a !== null ? s = [s, a] : (s = null, t = le)) : (s = null, t = le), s = s !== null ? s : "", s !== null ? (le = t, l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? a = [a, f] : (a = null, t = le)) : (a = null, t = le), a = a !== null ? a : "", a !== null ? (l.substr(t, 2) === "::" ? (f = "::", t += 2) : (f = null, i('"::"')), f !== null ? (S = ke(), S !== null ? e = [e, n, r, s, a, f, S] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (le = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? n = [n, r] : (n = null, t = le)) : (n = null, t = le), n = n !== null ? n : "", n !== null ? (le = t, l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? r = [r, s] : (r = null, t = le)) : (r = null, t = le), r = r !== null ? r : "", r !== null ? (le = t, l.charCodeAt(t) === 58 ? (s = ":", t++) : (s = null, i('":"')), s !== null ? (a = ie(), a !== null ? s = [s, a] : (s = null, t = le)) : (s = null, t = le), s = s !== null ? s : "", s !== null ? (le = t, l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? a = [a, f] : (a = null, t = le)) : (a = null, t = le), a = a !== null ? a : "", a !== null ? (le = t, l.charCodeAt(t) === 58 ? (f = ":", t++) : (f = null, i('":"')), f !== null ? (S = ie(), S !== null ? f = [f, S] : (f = null, t = le)) : (f = null, t = le), f = f !== null ? f : "", f !== null ? (l.substr(t, 2) === "::" ? (S = "::", t += 2) : (S = null, i('"::"')), S !== null ? (J = ie(), J !== null ? e = [e, n, r, s, a, f, S, J] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q), e === null && (Q = t, e = ie(), e !== null ? (le = t, l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? n = [n, r] : (n = null, t = le)) : (n = null, t = le), n = n !== null ? n : "", n !== null ? (le = t, l.charCodeAt(t) === 58 ? (r = ":", t++) : (r = null, i('":"')), r !== null ? (s = ie(), s !== null ? r = [r, s] : (r = null, t = le)) : (r = null, t = le), r = r !== null ? r : "", r !== null ? (le = t, l.charCodeAt(t) === 58 ? (s = ":", t++) : (s = null, i('":"')), s !== null ? (a = ie(), a !== null ? s = [s, a] : (s = null, t = le)) : (s = null, t = le), s = s !== null ? s : "", s !== null ? (le = t, l.charCodeAt(t) === 58 ? (a = ":", t++) : (a = null, i('":"')), a !== null ? (f = ie(), f !== null ? a = [a, f] : (a = null, t = le)) : (a = null, t = le), a = a !== null ? a : "", a !== null ? (le = t, l.charCodeAt(t) === 58 ? (f = ":", t++) : (f = null, i('":"')), f !== null ? (S = ie(), S !== null ? f = [f, S] : (f = null, t = le)) : (f = null, t = le), f = f !== null ? f : "", f !== null ? (le = t, l.charCodeAt(t) === 58 ? (S = ":", t++) : (S = null, i('":"')), S !== null ? (J = ie(), J !== null ? S = [S, J] : (S = null, t = le)) : (S = null, t = le), S = S !== null ? S : "", S !== null ? (l.substr(t, 2) === "::" ? (J = "::", t += 2) : (J = null, i('"::"')), J !== null ? e = [e, n, r, s, a, f, S, J] : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q)) : (e = null, t = Q))))))))))))))), e !== null && (e = function(cl) {
            return H.host_type = "IPv6", l.substring(t, cl);
          }(en)), e === null && (t = en), e;
        }
        function ie() {
          var e, n, r, s, a;
          return a = t, e = p(), e !== null ? (n = p(), n = n !== null ? n : "", n !== null ? (r = p(), r = r !== null ? r : "", r !== null ? (s = p(), s = s !== null ? s : "", s !== null ? e = [e, n, r, s] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e;
        }
        function ke() {
          var e, n, r, s;
          return s = t, e = ie(), e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = ie(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e === null && (e = et()), e;
        }
        function et() {
          var e, n, r, s, a, f, S, J, te;
          return J = t, te = t, e = tt(), e !== null ? (l.charCodeAt(t) === 46 ? (n = ".", t++) : (n = null, i('"."')), n !== null ? (r = tt(), r !== null ? (l.charCodeAt(t) === 46 ? (s = ".", t++) : (s = null, i('"."')), s !== null ? (a = tt(), a !== null ? (l.charCodeAt(t) === 46 ? (f = ".", t++) : (f = null, i('"."')), f !== null ? (S = tt(), S !== null ? e = [e, n, r, s, a, f, S] : (e = null, t = te)) : (e = null, t = te)) : (e = null, t = te)) : (e = null, t = te)) : (e = null, t = te)) : (e = null, t = te)) : (e = null, t = te), e !== null && (e = function(fe) {
            return H.host_type = "IPv4", l.substring(t, fe);
          }(J)), e === null && (t = J), e;
        }
        function tt() {
          var e, n, r, s;
          return s = t, l.substr(t, 2) === "25" ? (e = "25", t += 2) : (e = null, i('"25"')), e !== null ? (/^[0-5]/.test(l.charAt(t)) ? (n = l.charAt(t), t++) : (n = null, i("[0-5]")), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e === null && (s = t, l.charCodeAt(t) === 50 ? (e = "2", t++) : (e = null, i('"2"')), e !== null ? (/^[0-4]/.test(l.charAt(t)) ? (n = l.charAt(t), t++) : (n = null, i("[0-4]")), n !== null ? (r = o(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e === null && (s = t, l.charCodeAt(t) === 49 ? (e = "1", t++) : (e = null, i('"1"')), e !== null ? (n = o(), n !== null ? (r = o(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e === null && (s = t, /^[1-9]/.test(l.charAt(t)) ? (e = l.charAt(t), t++) : (e = null, i("[1-9]")), e !== null ? (n = o(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e === null && (e = o())))), e;
        }
        function zn() {
          var e, n, r, s, a, f, S;
          return f = t, S = t, e = o(), e = e !== null ? e : "", e !== null ? (n = o(), n = n !== null ? n : "", n !== null ? (r = o(), r = r !== null ? r : "", r !== null ? (s = o(), s = s !== null ? s : "", s !== null ? (a = o(), a = a !== null ? a : "", a !== null ? e = [e, n, r, s, a] : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S), e !== null && (e = function(J, te) {
            return te = parseInt(te.join("")), H.port = te, te;
          }(f, e)), e === null && (t = f), e;
        }
        function Yn() {
          var e, n, r, s;
          for (e = [], s = t, l.charCodeAt(t) === 59 ? (n = ";", t++) : (n = null, i('";"')), n !== null ? (r = Mt(), r !== null ? n = [n, r] : (n = null, t = s)) : (n = null, t = s); n !== null; )
            e.push(n), s = t, l.charCodeAt(t) === 59 ? (n = ";", t++) : (n = null, i('";"')), n !== null ? (r = Mt(), r !== null ? n = [n, r] : (n = null, t = s)) : (n = null, t = s);
          return e;
        }
        function Mt() {
          var e;
          return e = $n(), e === null && (e = Jn(), e === null && (e = Xn(), e === null && (e = Qn(), e === null && (e = Zn(), e === null && (e = er(), e === null && (e = tr())))))), e;
        }
        function $n() {
          var e, n, r, s;
          return r = t, s = t, l.substr(t, 10).toLowerCase() === "transport=" ? (e = l.substr(t, 10), t += 10) : (e = null, i('"transport="')), e !== null ? (l.substr(t, 3).toLowerCase() === "udp" ? (n = l.substr(t, 3), t += 3) : (n = null, i('"udp"')), n === null && (l.substr(t, 3).toLowerCase() === "tcp" ? (n = l.substr(t, 3), t += 3) : (n = null, i('"tcp"')), n === null && (l.substr(t, 4).toLowerCase() === "sctp" ? (n = l.substr(t, 4), t += 4) : (n = null, i('"sctp"')), n === null && (l.substr(t, 3).toLowerCase() === "tls" ? (n = l.substr(t, 3), t += 3) : (n = null, i('"tls"')), n === null && (n = R())))), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = function(a, f) {
            H.uri_params || (H.uri_params = {}), H.uri_params.transport = f.toLowerCase();
          }(r, e[1])), e === null && (t = r), e;
        }
        function Jn() {
          var e, n, r, s;
          return r = t, s = t, l.substr(t, 5).toLowerCase() === "user=" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"user="')), e !== null ? (l.substr(t, 5).toLowerCase() === "phone" ? (n = l.substr(t, 5), t += 5) : (n = null, i('"phone"')), n === null && (l.substr(t, 2).toLowerCase() === "ip" ? (n = l.substr(t, 2), t += 2) : (n = null, i('"ip"')), n === null && (n = R())), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = function(a, f) {
            H.uri_params || (H.uri_params = {}), H.uri_params.user = f.toLowerCase();
          }(r, e[1])), e === null && (t = r), e;
        }
        function Xn() {
          var e, n, r, s;
          return r = t, s = t, l.substr(t, 7).toLowerCase() === "method=" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"method="')), e !== null ? (n = vt(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = function(a, f) {
            H.uri_params || (H.uri_params = {}), H.uri_params.method = f;
          }(r, e[1])), e === null && (t = r), e;
        }
        function Qn() {
          var e, n, r, s;
          return r = t, s = t, l.substr(t, 4).toLowerCase() === "ttl=" ? (e = l.substr(t, 4), t += 4) : (e = null, i('"ttl="')), e !== null ? (n = Jt(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = function(a, f) {
            H.params || (H.params = {}), H.params.ttl = f;
          }(r, e[1])), e === null && (t = r), e;
        }
        function Zn() {
          var e, n, r, s;
          return r = t, s = t, l.substr(t, 6).toLowerCase() === "maddr=" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"maddr="')), e !== null ? (n = je(), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e !== null && (e = function(a, f) {
            H.uri_params || (H.uri_params = {}), H.uri_params.maddr = f;
          }(r, e[1])), e === null && (t = r), e;
        }
        function er() {
          var e, n, r, s, a, f;
          return s = t, a = t, l.substr(t, 2).toLowerCase() === "lr" ? (e = l.substr(t, 2), t += 2) : (e = null, i('"lr"')), e !== null ? (f = t, l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n !== null ? (r = R(), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S) {
            H.uri_params || (H.uri_params = {}), H.uri_params.lr = void 0;
          }()), e === null && (t = s), e;
        }
        function tr() {
          var e, n, r, s, a, f;
          return s = t, a = t, e = nr(), e !== null ? (f = t, l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n !== null ? (r = rr(), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S, J, te) {
            H.uri_params || (H.uri_params = {}), typeof te > "u" ? te = void 0 : te = te[1], H.uri_params[J.toLowerCase()] = te;
          }(s, e[0], e[1])), e === null && (t = s), e;
        }
        function nr() {
          var e, n, r;
          if (r = t, n = nt(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = nt();
          else
            e = null;
          return e !== null && (e = function(s, a) {
            return a.join("");
          }(r, e)), e === null && (t = r), e;
        }
        function rr() {
          var e, n, r;
          if (r = t, n = nt(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = nt();
          else
            e = null;
          return e !== null && (e = function(s, a) {
            return a.join("");
          }(r, e)), e === null && (t = r), e;
        }
        function nt() {
          var e;
          return e = sr(), e === null && (e = v(), e === null && (e = I())), e;
        }
        function sr() {
          var e;
          return l.charCodeAt(t) === 91 ? (e = "[", t++) : (e = null, i('"["')), e === null && (l.charCodeAt(t) === 93 ? (e = "]", t++) : (e = null, i('"]"')), e === null && (l.charCodeAt(t) === 47 ? (e = "/", t++) : (e = null, i('"/"')), e === null && (l.charCodeAt(t) === 58 ? (e = ":", t++) : (e = null, i('":"')), e === null && (l.charCodeAt(t) === 38 ? (e = "&", t++) : (e = null, i('"&"')), e === null && (l.charCodeAt(t) === 43 ? (e = "+", t++) : (e = null, i('"+"')), e === null && (l.charCodeAt(t) === 36 ? (e = "$", t++) : (e = null, i('"$"')))))))), e;
        }
        function ir() {
          var e, n, r, s, a, f, S;
          if (f = t, l.charCodeAt(t) === 63 ? (e = "?", t++) : (e = null, i('"?"')), e !== null)
            if (n = dt(), n !== null) {
              for (r = [], S = t, l.charCodeAt(t) === 38 ? (s = "&", t++) : (s = null, i('"&"')), s !== null ? (a = dt(), a !== null ? s = [s, a] : (s = null, t = S)) : (s = null, t = S); s !== null; )
                r.push(s), S = t, l.charCodeAt(t) === 38 ? (s = "&", t++) : (s = null, i('"&"')), s !== null ? (a = dt(), a !== null ? s = [s, a] : (s = null, t = S)) : (s = null, t = S);
              r !== null ? e = [e, n, r] : (e = null, t = f);
            } else
              e = null, t = f;
          else
            e = null, t = f;
          return e;
        }
        function dt() {
          var e, n, r, s, a;
          return s = t, a = t, e = lr(), e !== null ? (l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n !== null ? (r = ar(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S, J) {
            S = S.join("").toLowerCase(), J = J.join(""), H.uri_headers || (H.uri_headers = {}), H.uri_headers[S] ? H.uri_headers[S].push(J) : H.uri_headers[S] = [J];
          }(s, e[0], e[2])), e === null && (t = s), e;
        }
        function lr() {
          var e, n;
          if (n = rt(), n === null && (n = v(), n === null && (n = I())), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = rt(), n === null && (n = v(), n === null && (n = I()));
          else
            e = null;
          return e;
        }
        function ar() {
          var e, n;
          for (e = [], n = rt(), n === null && (n = v(), n === null && (n = I())); n !== null; )
            e.push(n), n = rt(), n === null && (n = v(), n === null && (n = I()));
          return e;
        }
        function rt() {
          var e;
          return l.charCodeAt(t) === 91 ? (e = "[", t++) : (e = null, i('"["')), e === null && (l.charCodeAt(t) === 93 ? (e = "]", t++) : (e = null, i('"]"')), e === null && (l.charCodeAt(t) === 47 ? (e = "/", t++) : (e = null, i('"/"')), e === null && (l.charCodeAt(t) === 63 ? (e = "?", t++) : (e = null, i('"?"')), e === null && (l.charCodeAt(t) === 58 ? (e = ":", t++) : (e = null, i('":"')), e === null && (l.charCodeAt(t) === 43 ? (e = "+", t++) : (e = null, i('"+"')), e === null && (l.charCodeAt(t) === 36 ? (e = "$", t++) : (e = null, i('"$"')))))))), e;
        }
        function Ii() {
          var e;
          return e = Or(), e === null && (e = or()), e;
        }
        function or() {
          var e, n, r, s, a, f;
          return f = t, e = vt(), e !== null ? (n = g(), n !== null ? (r = ur(), r !== null ? (s = g(), s !== null ? (a = Ht(), a !== null ? e = [e, n, r, s, a] : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f), e;
        }
        function ur() {
          var e;
          return e = ve(), e === null && (e = Lt()), e;
        }
        function Lt() {
          var e, n, r, s;
          return s = t, e = pr(), e !== null ? (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n !== null ? (r = fr(), r === null && (r = hr()), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function fr() {
          var e, n, r, s, a;
          return s = t, e = cr(), e === null && (e = _t()), e !== null ? (a = t, l.charCodeAt(t) === 63 ? (n = "?", t++) : (n = null, i('"?"')), n !== null ? (r = yr(), r !== null ? n = [n, r] : (n = null, t = a)) : (n = null, t = a), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e;
        }
        function cr() {
          var e, n, r, s;
          return s = t, l.substr(t, 2) === "//" ? (e = "//", t += 2) : (e = null, i('"//"')), e !== null ? (n = vr(), n !== null ? (r = _t(), r = r !== null ? r : "", r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function _t() {
          var e, n, r;
          return r = t, l.charCodeAt(t) === 47 ? (e = "/", t++) : (e = null, i('"/"')), e !== null ? (n = _r(), n !== null ? e = [e, n] : (e = null, t = r)) : (e = null, t = r), e;
        }
        function hr() {
          var e, n, r, s;
          if (s = t, e = dr(), e !== null) {
            for (n = [], r = st(); r !== null; )
              n.push(r), r = st();
            n !== null ? e = [e, n] : (e = null, t = s);
          } else
            e = null, t = s;
          return e;
        }
        function st() {
          var e;
          return e = T(), e === null && (e = v(), e === null && (e = I())), e;
        }
        function dr() {
          var e;
          return e = v(), e === null && (e = I(), e === null && (l.charCodeAt(t) === 59 ? (e = ";", t++) : (e = null, i('";"')), e === null && (l.charCodeAt(t) === 63 ? (e = "?", t++) : (e = null, i('"?"')), e === null && (l.charCodeAt(t) === 58 ? (e = ":", t++) : (e = null, i('":"')), e === null && (l.charCodeAt(t) === 64 ? (e = "@", t++) : (e = null, i('"@"')), e === null && (l.charCodeAt(t) === 38 ? (e = "&", t++) : (e = null, i('"&"')), e === null && (l.charCodeAt(t) === 61 ? (e = "=", t++) : (e = null, i('"="')), e === null && (l.charCodeAt(t) === 43 ? (e = "+", t++) : (e = null, i('"+"')), e === null && (l.charCodeAt(t) === 36 ? (e = "$", t++) : (e = null, i('"$"')), e === null && (l.charCodeAt(t) === 44 ? (e = ",", t++) : (e = null, i('","')))))))))))), e;
        }
        function _r() {
          var e, n, r, s, a, f;
          if (a = t, e = pt(), e !== null) {
            for (n = [], f = t, l.charCodeAt(t) === 47 ? (r = "/", t++) : (r = null, i('"/"')), r !== null ? (s = pt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, l.charCodeAt(t) === 47 ? (r = "/", t++) : (r = null, i('"/"')), r !== null ? (s = pt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function pt() {
          var e, n, r, s, a, f;
          for (a = t, e = [], n = it(); n !== null; )
            e.push(n), n = it();
          if (e !== null) {
            for (n = [], f = t, l.charCodeAt(t) === 59 ? (r = ";", t++) : (r = null, i('";"')), r !== null ? (s = Ft(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, l.charCodeAt(t) === 59 ? (r = ";", t++) : (r = null, i('";"')), r !== null ? (s = Ft(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function Ft() {
          var e, n;
          for (e = [], n = it(); n !== null; )
            e.push(n), n = it();
          return e;
        }
        function it() {
          var e;
          return e = v(), e === null && (e = I(), e === null && (l.charCodeAt(t) === 58 ? (e = ":", t++) : (e = null, i('":"')), e === null && (l.charCodeAt(t) === 64 ? (e = "@", t++) : (e = null, i('"@"')), e === null && (l.charCodeAt(t) === 38 ? (e = "&", t++) : (e = null, i('"&"')), e === null && (l.charCodeAt(t) === 61 ? (e = "=", t++) : (e = null, i('"="')), e === null && (l.charCodeAt(t) === 43 ? (e = "+", t++) : (e = null, i('"+"')), e === null && (l.charCodeAt(t) === 36 ? (e = "$", t++) : (e = null, i('"$"')), e === null && (l.charCodeAt(t) === 44 ? (e = ",", t++) : (e = null, i('","')))))))))), e;
        }
        function pr() {
          var e, n, r, s, a;
          if (s = t, a = t, e = h(), e !== null) {
            for (n = [], r = h(), r === null && (r = o(), r === null && (l.charCodeAt(t) === 43 ? (r = "+", t++) : (r = null, i('"+"')), r === null && (l.charCodeAt(t) === 45 ? (r = "-", t++) : (r = null, i('"-"')), r === null && (l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."')))))); r !== null; )
              n.push(r), r = h(), r === null && (r = o(), r === null && (l.charCodeAt(t) === 43 ? (r = "+", t++) : (r = null, i('"+"')), r === null && (l.charCodeAt(t) === 45 ? (r = "-", t++) : (r = null, i('"-"')), r === null && (l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."'))))));
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e !== null && (e = function(f) {
            H.scheme = l.substring(t, f);
          }(s)), e === null && (t = s), e;
        }
        function vr() {
          var e;
          return e = mr(), e === null && (e = gr()), e;
        }
        function mr() {
          var e, n, r, s;
          return r = t, s = t, e = we(), e !== null ? (l.charCodeAt(t) === 64 ? (n = "@", t++) : (n = null, i('"@"')), n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e = e !== null ? e : "", e !== null ? (n = qe(), n !== null ? e = [e, n] : (e = null, t = r)) : (e = null, t = r), e = e !== null ? e : "", e;
        }
        function gr() {
          var e, n;
          if (n = v(), n === null && (n = I(), n === null && (l.charCodeAt(t) === 36 ? (n = "$", t++) : (n = null, i('"$"')), n === null && (l.charCodeAt(t) === 44 ? (n = ",", t++) : (n = null, i('","')), n === null && (l.charCodeAt(t) === 59 ? (n = ";", t++) : (n = null, i('";"')), n === null && (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n === null && (l.charCodeAt(t) === 64 ? (n = "@", t++) : (n = null, i('"@"')), n === null && (l.charCodeAt(t) === 38 ? (n = "&", t++) : (n = null, i('"&"')), n === null && (l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"'))))))))))), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = v(), n === null && (n = I(), n === null && (l.charCodeAt(t) === 36 ? (n = "$", t++) : (n = null, i('"$"')), n === null && (l.charCodeAt(t) === 44 ? (n = ",", t++) : (n = null, i('","')), n === null && (l.charCodeAt(t) === 59 ? (n = ";", t++) : (n = null, i('";"')), n === null && (l.charCodeAt(t) === 58 ? (n = ":", t++) : (n = null, i('":"')), n === null && (l.charCodeAt(t) === 64 ? (n = "@", t++) : (n = null, i('"@"')), n === null && (l.charCodeAt(t) === 38 ? (n = "&", t++) : (n = null, i('"&"')), n === null && (l.charCodeAt(t) === 61 ? (n = "=", t++) : (n = null, i('"="')), n === null && (l.charCodeAt(t) === 43 ? (n = "+", t++) : (n = null, i('"+"')))))))))));
          else
            e = null;
          return e;
        }
        function yr() {
          var e, n;
          for (e = [], n = st(); n !== null; )
            e.push(n), n = st();
          return e;
        }
        function Ht() {
          var e, n, r, s, a, f, S, J;
          if (S = t, J = t, l.substr(t, 3).toLowerCase() === "sip" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"SIP"')), e !== null)
            if (l.charCodeAt(t) === 47 ? (n = "/", t++) : (n = null, i('"/"')), n !== null) {
              if (s = o(), s !== null)
                for (r = []; s !== null; )
                  r.push(s), s = o();
              else
                r = null;
              if (r !== null)
                if (l.charCodeAt(t) === 46 ? (s = ".", t++) : (s = null, i('"."')), s !== null) {
                  if (f = o(), f !== null)
                    for (a = []; f !== null; )
                      a.push(f), f = o();
                  else
                    a = null;
                  a !== null ? e = [e, n, r, s, a] : (e = null, t = J);
                } else
                  e = null, t = J;
              else
                e = null, t = J;
            } else
              e = null, t = J;
          else
            e = null, t = J;
          return e !== null && (e = function(te) {
            H.sip_version = l.substring(t, te);
          }(S)), e === null && (t = S), e;
        }
        function Tr() {
          var e;
          return l.substr(t, 6) === "INVITE" ? (e = "INVITE", t += 6) : (e = null, i('"INVITE"')), e;
        }
        function Sr() {
          var e;
          return l.substr(t, 3) === "ACK" ? (e = "ACK", t += 3) : (e = null, i('"ACK"')), e;
        }
        function Cr() {
          var e;
          return l.substr(t, 7) === "OPTIONS" ? (e = "OPTIONS", t += 7) : (e = null, i('"OPTIONS"')), e;
        }
        function Er() {
          var e;
          return l.substr(t, 3) === "BYE" ? (e = "BYE", t += 3) : (e = null, i('"BYE"')), e;
        }
        function Ar() {
          var e;
          return l.substr(t, 6) === "CANCEL" ? (e = "CANCEL", t += 6) : (e = null, i('"CANCEL"')), e;
        }
        function br() {
          var e;
          return l.substr(t, 8) === "REGISTER" ? (e = "REGISTER", t += 8) : (e = null, i('"REGISTER"')), e;
        }
        function Rr() {
          var e;
          return l.substr(t, 9) === "SUBSCRIBE" ? (e = "SUBSCRIBE", t += 9) : (e = null, i('"SUBSCRIBE"')), e;
        }
        function wr() {
          var e;
          return l.substr(t, 6) === "NOTIFY" ? (e = "NOTIFY", t += 6) : (e = null, i('"NOTIFY"')), e;
        }
        function Ir() {
          var e;
          return l.substr(t, 5) === "REFER" ? (e = "REFER", t += 5) : (e = null, i('"REFER"')), e;
        }
        function vt() {
          var e, n;
          return n = t, e = Tr(), e === null && (e = Sr(), e === null && (e = Cr(), e === null && (e = Er(), e === null && (e = Ar(), e === null && (e = br(), e === null && (e = Rr(), e === null && (e = wr(), e === null && (e = Ir(), e === null && (e = R()))))))))), e !== null && (e = function(r) {
            return H.method = l.substring(t, r), H.method;
          }(n)), e === null && (t = n), e;
        }
        function Or() {
          var e, n, r, s, a, f;
          return f = t, e = Ht(), e !== null ? (n = g(), n !== null ? (r = Nr(), r !== null ? (s = g(), s !== null ? (a = Dr(), a !== null ? e = [e, n, r, s, a] : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f), e;
        }
        function Nr() {
          var e, n;
          return n = t, e = kr(), e !== null && (e = function(r, s) {
            H.status_code = parseInt(s.join(""));
          }(n, e)), e === null && (t = n), e;
        }
        function kr() {
          var e, n, r, s;
          return s = t, e = o(), e !== null ? (n = o(), n !== null ? (r = o(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Dr() {
          var e, n, r;
          for (r = t, e = [], n = T(), n === null && (n = v(), n === null && (n = I(), n === null && (n = B(), n === null && (n = d(), n === null && (n = g(), n === null && (n = k())))))); n !== null; )
            e.push(n), n = T(), n === null && (n = v(), n === null && (n = I(), n === null && (n = B(), n === null && (n = d(), n === null && (n = g(), n === null && (n = k()))))));
          return e !== null && (e = function(s) {
            H.reason_phrase = l.substring(t, s);
          }(r)), e === null && (t = r), e;
        }
        function Oi() {
          var e, n, r, s, a, f;
          if (a = t, e = lt(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = lt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = lt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function Ni() {
          var e, n, r, s, a, f;
          return s = t, a = t, e = V(), e !== null ? (f = t, l.charCodeAt(t) === 64 ? (n = "@", t++) : (n = null, i('"@"')), n !== null ? (r = V(), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S) {
            H = l.substring(t, S);
          }(s)), e === null && (t = s), e;
        }
        function ki() {
          var e, n, r, s, a, f, S;
          if (a = t, e = x(), e === null)
            if (f = t, e = mt(), e !== null) {
              for (n = [], S = t, r = ee(), r !== null ? (s = mt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
                n.push(r), S = t, r = ee(), r !== null ? (s = mt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
              n !== null ? e = [e, n] : (e = null, t = f);
            } else
              e = null, t = f;
          return e !== null && (e = function(J) {
            var te, fe;
            for (fe = H.multi_header.length, te = 0; te < fe; te++)
              if (H.multi_header[te].parsed === null) {
                H = null;
                break;
              }
            H !== null ? H = H.multi_header : H = -1;
          }()), e === null && (t = a), e;
        }
        function mt() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = _e(), e === null && (e = We()), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = qt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = qt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            var te;
            H.multi_header || (H.multi_header = []);
            try {
              te = new Je(H.uri, H.display_name, H.params), delete H.uri, delete H.display_name, delete H.params;
            } catch {
              te = null;
            }
            H.multi_header.push({
              possition: t,
              offset: J,
              parsed: te
            });
          }(a)), e === null && (t = a), e;
        }
        function We() {
          var e, n, r, s, a;
          return a = t, e = gt(), e = e !== null ? e : "", e !== null ? (n = z(), n !== null ? (r = ve(), r !== null ? (s = $(), s !== null ? e = [e, n, r, s] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e;
        }
        function gt() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = R(), e !== null) {
            for (n = [], S = t, r = C(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = C(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e === null && (e = ue()), e !== null && (e = function(J, te) {
            typeof te == "string" ? H.display_name = te : H.display_name = te[1].reduce(function(fe, ge) {
              return fe + ge[0] + ge[1];
            }, te[0]);
          }(a, e)), e === null && (t = a), e;
        }
        function qt() {
          var e;
          return e = Pr(), e === null && (e = xr(), e === null && (e = Ae())), e;
        }
        function Pr() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 1).toLowerCase() === "q" ? (e = l.substr(t, 1), t++) : (e = null, i('"q"')), e !== null ? (n = m(), n !== null ? (r = Ur(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.params || (H.params = {}), H.params.q = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function xr() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 7).toLowerCase() === "expires" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"expires"')), e !== null ? (n = m(), n !== null ? (r = Ke(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.params || (H.params = {}), H.params.expires = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function Ke() {
          var e, n, r;
          if (r = t, n = o(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = o();
          else
            e = null;
          return e !== null && (e = function(s, a) {
            return parseInt(a.join(""));
          }(r, e)), e === null && (t = r), e;
        }
        function Ur() {
          var e, n, r, s, a, f, S, J;
          return f = t, S = t, l.charCodeAt(t) === 48 ? (e = "0", t++) : (e = null, i('"0"')), e !== null ? (J = t, l.charCodeAt(t) === 46 ? (n = ".", t++) : (n = null, i('"."')), n !== null ? (r = o(), r = r !== null ? r : "", r !== null ? (s = o(), s = s !== null ? s : "", s !== null ? (a = o(), a = a !== null ? a : "", a !== null ? n = [n, r, s, a] : (n = null, t = J)) : (n = null, t = J)) : (n = null, t = J)) : (n = null, t = J), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = S)) : (e = null, t = S), e !== null && (e = function(te) {
            return parseFloat(l.substring(t, te));
          }(f)), e === null && (t = f), e;
        }
        function Ae() {
          var e, n, r, s, a, f;
          return s = t, a = t, e = R(), e !== null ? (f = t, n = m(), n !== null ? (r = Mr(), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S, J, te) {
            H.params || (H.params = {}), typeof te > "u" ? te = void 0 : te = te[1], H.params[J.toLowerCase()] = te;
          }(s, e[0], e[1])), e === null && (t = s), e;
        }
        function Mr() {
          var e;
          return e = R(), e === null && (e = je(), e === null && (e = Te())), e;
        }
        function Di() {
          var e, n, r, s, a, f;
          if (a = t, e = Lr(), e !== null) {
            for (n = [], f = t, r = Z(), r !== null ? (s = jt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = Z(), r !== null ? (s = jt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function Lr() {
          var e;
          return l.substr(t, 6).toLowerCase() === "render" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"render"')), e === null && (l.substr(t, 7).toLowerCase() === "session" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"session"')), e === null && (l.substr(t, 4).toLowerCase() === "icon" ? (e = l.substr(t, 4), t += 4) : (e = null, i('"icon"')), e === null && (l.substr(t, 5).toLowerCase() === "alert" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"alert"')), e === null && (e = R())))), e;
        }
        function jt() {
          var e;
          return e = Fr(), e === null && (e = Ae()), e;
        }
        function Fr() {
          var e, n, r, s;
          return s = t, l.substr(t, 8).toLowerCase() === "handling" ? (e = l.substr(t, 8), t += 8) : (e = null, i('"handling"')), e !== null ? (n = m(), n !== null ? (l.substr(t, 8).toLowerCase() === "optional" ? (r = l.substr(t, 8), t += 8) : (r = null, i('"optional"')), r === null && (l.substr(t, 8).toLowerCase() === "required" ? (r = l.substr(t, 8), t += 8) : (r = null, i('"required"')), r === null && (r = R())), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Pi() {
          var e, n, r, s, a, f;
          if (a = t, e = R(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function xi() {
          var e, n, r;
          if (r = t, n = o(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = o();
          else
            e = null;
          return e !== null && (e = function(s, a) {
            H = parseInt(a.join(""));
          }(r, e)), e === null && (t = r), e;
        }
        function Ui() {
          var e, n;
          return n = t, e = Hr(), e !== null && (e = function(r) {
            H = l.substring(t, r);
          }(n)), e === null && (t = n), e;
        }
        function Hr() {
          var e, n, r, s, a, f, S, J;
          if (S = t, e = qr(), e !== null)
            if (n = u(), n !== null)
              if (r = Br(), r !== null) {
                for (s = [], J = t, a = Z(), a !== null ? (f = Gt(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J); a !== null; )
                  s.push(a), J = t, a = Z(), a !== null ? (f = Gt(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J);
                s !== null ? e = [e, n, r, s] : (e = null, t = S);
              } else
                e = null, t = S;
            else
              e = null, t = S;
          else
            e = null, t = S;
          return e;
        }
        function qr() {
          var e;
          return e = jr(), e === null && (e = Gr()), e;
        }
        function jr() {
          var e;
          return l.substr(t, 4).toLowerCase() === "text" ? (e = l.substr(t, 4), t += 4) : (e = null, i('"text"')), e === null && (l.substr(t, 5).toLowerCase() === "image" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"image"')), e === null && (l.substr(t, 5).toLowerCase() === "audio" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"audio"')), e === null && (l.substr(t, 5).toLowerCase() === "video" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"video"')), e === null && (l.substr(t, 11).toLowerCase() === "application" ? (e = l.substr(t, 11), t += 11) : (e = null, i('"application"')), e === null && (e = yt()))))), e;
        }
        function Gr() {
          var e;
          return l.substr(t, 7).toLowerCase() === "message" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"message"')), e === null && (l.substr(t, 9).toLowerCase() === "multipart" ? (e = l.substr(t, 9), t += 9) : (e = null, i('"multipart"')), e === null && (e = yt())), e;
        }
        function yt() {
          var e;
          return e = R(), e === null && (e = Vr()), e;
        }
        function Vr() {
          var e, n, r;
          return r = t, l.substr(t, 2).toLowerCase() === "x-" ? (e = l.substr(t, 2), t += 2) : (e = null, i('"x-"')), e !== null ? (n = R(), n !== null ? e = [e, n] : (e = null, t = r)) : (e = null, t = r), e;
        }
        function Br() {
          var e;
          return e = yt(), e === null && (e = R()), e;
        }
        function Gt() {
          var e, n, r, s;
          return s = t, e = R(), e !== null ? (n = m(), n !== null ? (r = Wr(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Wr() {
          var e;
          return e = R(), e === null && (e = Te()), e;
        }
        function Mi() {
          var e, n, r, s;
          return s = t, e = Kr(), e !== null ? (n = C(), n !== null ? (r = vt(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Kr() {
          var e, n, r;
          if (r = t, n = o(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = o();
          else
            e = null;
          return e !== null && (e = function(s, a) {
            H.value = parseInt(a.join(""));
          }(r, e)), e === null && (t = r), e;
        }
        function Li() {
          var e, n;
          return n = t, e = Ke(), e !== null && (e = function(r, s) {
            H = s;
          }(n, e)), e === null && (t = n), e;
        }
        function Fi() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = lt(), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J, te) {
            H.event = te.join("").toLowerCase();
          }(a, e[0])), e === null && (t = a), e;
        }
        function lt() {
          var e, n, r, s, a, f;
          if (a = t, e = A(), e !== null) {
            for (n = [], f = t, l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."')), r !== null ? (s = A(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, l.charCodeAt(t) === 46 ? (r = ".", t++) : (r = null, i('"."')), r !== null ? (s = A(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function Hi() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = _e(), e === null && (e = We()), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = Vt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = Vt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            var te = H.tag;
            try {
              H = new Je(H.uri, H.display_name, H.params), te && H.setParam("tag", te);
            } catch {
              H = -1;
            }
          }()), e === null && (t = a), e;
        }
        function Vt() {
          var e;
          return e = Bt(), e === null && (e = Ae()), e;
        }
        function Bt() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 3).toLowerCase() === "tag" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"tag"')), e !== null ? (n = m(), n !== null ? (r = R(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.tag = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function qi() {
          var e, n, r;
          if (r = t, n = o(), n !== null)
            for (e = []; n !== null; )
              e.push(n), n = o();
          else
            e = null;
          return e !== null && (e = function(s, a) {
            H = parseInt(a.join(""));
          }(r, e)), e === null && (t = r), e;
        }
        function ji() {
          var e, n;
          return n = t, e = Ke(), e !== null && (e = function(r, s) {
            H = s;
          }(n, e)), e === null && (t = n), e;
        }
        function Gi() {
          var e, n, r, s, a, f, S, J, te, fe;
          for (J = t, te = t, e = [], n = gt(); n !== null; )
            e.push(n), n = gt();
          if (e !== null)
            if (n = z(), n !== null)
              if (r = ve(), r !== null)
                if (s = $(), s !== null) {
                  for (a = [], fe = t, f = Z(), f !== null ? (S = Ae(), S !== null ? f = [f, S] : (f = null, t = fe)) : (f = null, t = fe); f !== null; )
                    a.push(f), fe = t, f = Z(), f !== null ? (S = Ae(), S !== null ? f = [f, S] : (f = null, t = fe)) : (f = null, t = fe);
                  a !== null ? e = [e, n, r, s, a] : (e = null, t = te);
                } else
                  e = null, t = te;
              else
                e = null, t = te;
            else
              e = null, t = te;
          else
            e = null, t = te;
          return e !== null && (e = function(ge) {
            try {
              H = new Je(H.uri, H.display_name, H.params);
            } catch {
              H = -1;
            }
          }()), e === null && (t = J), e;
        }
        function Vi() {
          var e;
          return e = Wt(), e;
        }
        function Wt() {
          var e, n, r, s, a, f, S, J;
          if (S = t, l.substr(t, 6).toLowerCase() === "digest" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"Digest"')), e !== null)
            if (n = C(), n !== null)
              if (r = Tt(), r !== null) {
                for (s = [], J = t, a = ee(), a !== null ? (f = Tt(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J); a !== null; )
                  s.push(a), J = t, a = ee(), a !== null ? (f = Tt(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J);
                s !== null ? e = [e, n, r, s] : (e = null, t = S);
              } else
                e = null, t = S;
            else
              e = null, t = S;
          else
            e = null, t = S;
          return e === null && (e = zr()), e;
        }
        function zr() {
          var e, n, r, s, a, f, S, J;
          if (S = t, e = R(), e !== null)
            if (n = C(), n !== null)
              if (r = at(), r !== null) {
                for (s = [], J = t, a = ee(), a !== null ? (f = at(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J); a !== null; )
                  s.push(a), J = t, a = ee(), a !== null ? (f = at(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J);
                s !== null ? e = [e, n, r, s] : (e = null, t = S);
              } else
                e = null, t = S;
            else
              e = null, t = S;
          else
            e = null, t = S;
          return e;
        }
        function at() {
          var e, n, r, s;
          return s = t, e = R(), e !== null ? (n = m(), n !== null ? (r = R(), r === null && (r = Te()), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Tt() {
          var e;
          return e = Yr(), e === null && (e = Jr(), e === null && (e = Xr(), e === null && (e = Zr(), e === null && (e = es(), e === null && (e = ts(), e === null && (e = ns(), e === null && (e = at()))))))), e;
        }
        function Yr() {
          var e, n, r, s;
          return s = t, l.substr(t, 5).toLowerCase() === "realm" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"realm"')), e !== null ? (n = m(), n !== null ? (r = $r(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function $r() {
          var e, n;
          return n = t, e = ue(), e !== null && (e = function(r, s) {
            H.realm = s;
          }(n, e)), e === null && (t = n), e;
        }
        function Jr() {
          var e, n, r, s, a, f, S, J, te;
          if (J = t, l.substr(t, 6).toLowerCase() === "domain" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"domain"')), e !== null)
            if (n = m(), n !== null)
              if (r = se(), r !== null)
                if (s = St(), s !== null) {
                  if (a = [], te = t, S = g(), S !== null)
                    for (f = []; S !== null; )
                      f.push(S), S = g();
                  else
                    f = null;
                  for (f !== null ? (S = St(), S !== null ? f = [f, S] : (f = null, t = te)) : (f = null, t = te); f !== null; ) {
                    if (a.push(f), te = t, S = g(), S !== null)
                      for (f = []; S !== null; )
                        f.push(S), S = g();
                    else
                      f = null;
                    f !== null ? (S = St(), S !== null ? f = [f, S] : (f = null, t = te)) : (f = null, t = te);
                  }
                  a !== null ? (f = ne(), f !== null ? e = [e, n, r, s, a, f] : (e = null, t = J)) : (e = null, t = J);
                } else
                  e = null, t = J;
              else
                e = null, t = J;
            else
              e = null, t = J;
          else
            e = null, t = J;
          return e;
        }
        function St() {
          var e;
          return e = Lt(), e === null && (e = _t()), e;
        }
        function Xr() {
          var e, n, r, s;
          return s = t, l.substr(t, 5).toLowerCase() === "nonce" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"nonce"')), e !== null ? (n = m(), n !== null ? (r = Qr(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Qr() {
          var e, n;
          return n = t, e = ue(), e !== null && (e = function(r, s) {
            H.nonce = s;
          }(n, e)), e === null && (t = n), e;
        }
        function Zr() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 6).toLowerCase() === "opaque" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"opaque"')), e !== null ? (n = m(), n !== null ? (r = ue(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.opaque = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function es() {
          var e, n, r, s, a;
          return s = t, l.substr(t, 5).toLowerCase() === "stale" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"stale"')), e !== null ? (n = m(), n !== null ? (a = t, l.substr(t, 4).toLowerCase() === "true" ? (r = l.substr(t, 4), t += 4) : (r = null, i('"true"')), r !== null && (r = function(f) {
            H.stale = !0;
          }()), r === null && (t = a), r === null && (a = t, l.substr(t, 5).toLowerCase() === "false" ? (r = l.substr(t, 5), t += 5) : (r = null, i('"false"')), r !== null && (r = function(f) {
            H.stale = !1;
          }()), r === null && (t = a)), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function ts() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 9).toLowerCase() === "algorithm" ? (e = l.substr(t, 9), t += 9) : (e = null, i('"algorithm"')), e !== null ? (n = m(), n !== null ? (l.substr(t, 3).toLowerCase() === "md5" ? (r = l.substr(t, 3), t += 3) : (r = null, i('"MD5"')), r === null && (l.substr(t, 8).toLowerCase() === "md5-sess" ? (r = l.substr(t, 8), t += 8) : (r = null, i('"MD5-sess"')), r === null && (r = R())), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.algorithm = S.toUpperCase();
          }(s, e[2])), e === null && (t = s), e;
        }
        function ns() {
          var e, n, r, s, a, f, S, J, te, fe;
          if (J = t, l.substr(t, 3).toLowerCase() === "qop" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"qop"')), e !== null)
            if (n = m(), n !== null)
              if (r = se(), r !== null) {
                if (te = t, s = Ct(), s !== null) {
                  for (a = [], fe = t, l.charCodeAt(t) === 44 ? (f = ",", t++) : (f = null, i('","')), f !== null ? (S = Ct(), S !== null ? f = [f, S] : (f = null, t = fe)) : (f = null, t = fe); f !== null; )
                    a.push(f), fe = t, l.charCodeAt(t) === 44 ? (f = ",", t++) : (f = null, i('","')), f !== null ? (S = Ct(), S !== null ? f = [f, S] : (f = null, t = fe)) : (f = null, t = fe);
                  a !== null ? s = [s, a] : (s = null, t = te);
                } else
                  s = null, t = te;
                s !== null ? (a = ne(), a !== null ? e = [e, n, r, s, a] : (e = null, t = J)) : (e = null, t = J);
              } else
                e = null, t = J;
            else
              e = null, t = J;
          else
            e = null, t = J;
          return e;
        }
        function Ct() {
          var e, n;
          return n = t, l.substr(t, 8).toLowerCase() === "auth-int" ? (e = l.substr(t, 8), t += 8) : (e = null, i('"auth-int"')), e === null && (l.substr(t, 4).toLowerCase() === "auth" ? (e = l.substr(t, 4), t += 4) : (e = null, i('"auth"')), e === null && (e = R())), e !== null && (e = function(r, s) {
            H.qop || (H.qop = []), H.qop.push(s.toLowerCase());
          }(n, e)), e === null && (t = n), e;
        }
        function Bi() {
          var e, n, r, s, a, f;
          if (a = t, e = R(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function Wi() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = Et(), e !== null) {
            for (n = [], S = t, r = ee(), r !== null ? (s = Et(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = ee(), r !== null ? (s = Et(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            var te, fe;
            for (fe = H.multi_header.length, te = 0; te < fe; te++)
              if (H.multi_header[te].parsed === null) {
                H = null;
                break;
              }
            H !== null ? H = H.multi_header : H = -1;
          }()), e === null && (t = a), e;
        }
        function Et() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = We(), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            var te;
            H.multi_header || (H.multi_header = []);
            try {
              te = new Je(H.uri, H.display_name, H.params), delete H.uri, delete H.display_name, delete H.params;
            } catch {
              te = null;
            }
            H.multi_header.push({
              possition: t,
              offset: J,
              parsed: te
            });
          }(a)), e === null && (t = a), e;
        }
        function Ki() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, l.substr(t, 3).toLowerCase() === "sip" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"SIP"')), e === null && (e = R()), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = Kt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = Kt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J, te) {
            if (H.protocol = te.toLowerCase(), H.params || (H.params = {}), H.params.text && H.params.text[0] === '"') {
              var fe = H.params.text;
              H.text = fe.substring(1, fe.length - 1), delete H.params.text;
            }
          }(a, e[0])), e === null && (t = a), e;
        }
        function Kt() {
          var e;
          return e = rs(), e === null && (e = Ae()), e;
        }
        function rs() {
          var e, n, r, s, a, f;
          if (a = t, f = t, l.substr(t, 5).toLowerCase() === "cause" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"cause"')), e !== null)
            if (n = m(), n !== null) {
              if (s = o(), s !== null)
                for (r = []; s !== null; )
                  r.push(s), s = o();
              else
                r = null;
              r !== null ? e = [e, n, r] : (e = null, t = f);
            } else
              e = null, t = f;
          else
            e = null, t = f;
          return e !== null && (e = function(S, J) {
            H.cause = parseInt(J.join(""));
          }(a, e[2])), e === null && (t = a), e;
        }
        function zi() {
          var e, n, r, s, a, f;
          if (a = t, e = R(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function Yi() {
          var e, n, r, s, a, f;
          if (a = t, e = At(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = At(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = At(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function At() {
          var e, n, r, s, a, f;
          if (a = t, e = We(), e !== null) {
            for (n = [], f = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function $i() {
          var e, n, r, s, a, f;
          if (a = t, e = ss(), e !== null) {
            for (n = [], f = t, r = Z(), r !== null ? (s = zt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = Z(), r !== null ? (s = zt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function ss() {
          var e, n;
          return n = t, l.substr(t, 6).toLowerCase() === "active" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"active"')), e === null && (l.substr(t, 7).toLowerCase() === "pending" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"pending"')), e === null && (l.substr(t, 10).toLowerCase() === "terminated" ? (e = l.substr(t, 10), t += 10) : (e = null, i('"terminated"')), e === null && (e = R()))), e !== null && (e = function(r) {
            H.state = l.substring(t, r);
          }(n)), e === null && (t = n), e;
        }
        function zt() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 6).toLowerCase() === "reason" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"reason"')), e !== null ? (n = m(), n !== null ? (r = is(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            typeof S < "u" && (H.reason = S);
          }(s, e[2])), e === null && (t = s), e === null && (s = t, a = t, l.substr(t, 7).toLowerCase() === "expires" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"expires"')), e !== null ? (n = m(), n !== null ? (r = Ke(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            typeof S < "u" && (H.expires = S);
          }(s, e[2])), e === null && (t = s), e === null && (s = t, a = t, l.substr(t, 11).toLowerCase() === "retry_after" ? (e = l.substr(t, 11), t += 11) : (e = null, i('"retry_after"')), e !== null ? (n = m(), n !== null ? (r = Ke(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            typeof S < "u" && (H.retry_after = S);
          }(s, e[2])), e === null && (t = s), e === null && (e = Ae()))), e;
        }
        function is() {
          var e;
          return l.substr(t, 11).toLowerCase() === "deactivated" ? (e = l.substr(t, 11), t += 11) : (e = null, i('"deactivated"')), e === null && (l.substr(t, 9).toLowerCase() === "probation" ? (e = l.substr(t, 9), t += 9) : (e = null, i('"probation"')), e === null && (l.substr(t, 8).toLowerCase() === "rejected" ? (e = l.substr(t, 8), t += 8) : (e = null, i('"rejected"')), e === null && (l.substr(t, 7).toLowerCase() === "timeout" ? (e = l.substr(t, 7), t += 7) : (e = null, i('"timeout"')), e === null && (l.substr(t, 6).toLowerCase() === "giveup" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"giveup"')), e === null && (l.substr(t, 10).toLowerCase() === "noresource" ? (e = l.substr(t, 10), t += 10) : (e = null, i('"noresource"')), e === null && (l.substr(t, 9).toLowerCase() === "invariant" ? (e = l.substr(t, 9), t += 9) : (e = null, i('"invariant"')), e === null && (e = R()))))))), e;
        }
        function Ji() {
          var e;
          return e = Y(), e = e !== null ? e : "", e;
        }
        function Xi() {
          var e, n, r, s, a, f;
          if (a = t, e = R(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = R(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e = e !== null ? e : "", e;
        }
        function Qi() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = _e(), e === null && (e = We()), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = Yt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = Yt(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            var te = H.tag;
            try {
              H = new Je(H.uri, H.display_name, H.params), te && H.setParam("tag", te);
            } catch {
              H = -1;
            }
          }()), e === null && (t = a), e;
        }
        function Yt() {
          var e;
          return e = Bt(), e === null && (e = Ae()), e;
        }
        function Zi() {
          var e, n, r, s, a, f;
          if (a = t, e = bt(), e !== null) {
            for (n = [], f = t, r = ee(), r !== null ? (s = bt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = ee(), r !== null ? (s = bt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function bt() {
          var e, n, r, s, a, f, S, J;
          if (S = t, e = hs(), e !== null)
            if (n = C(), n !== null)
              if (r = ps(), r !== null) {
                for (s = [], J = t, a = Z(), a !== null ? (f = $t(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J); a !== null; )
                  s.push(a), J = t, a = Z(), a !== null ? (f = $t(), f !== null ? a = [a, f] : (a = null, t = J)) : (a = null, t = J);
                s !== null ? e = [e, n, r, s] : (e = null, t = S);
              } else
                e = null, t = S;
            else
              e = null, t = S;
          else
            e = null, t = S;
          return e;
        }
        function $t() {
          var e;
          return e = ls(), e === null && (e = as(), e === null && (e = os(), e === null && (e = us(), e === null && (e = fs(), e === null && (e = Ae()))))), e;
        }
        function ls() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 3).toLowerCase() === "ttl" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"ttl"')), e !== null ? (n = m(), n !== null ? (r = Jt(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.ttl = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function as() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 5).toLowerCase() === "maddr" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"maddr"')), e !== null ? (n = m(), n !== null ? (r = je(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.maddr = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function os() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 8).toLowerCase() === "received" ? (e = l.substr(t, 8), t += 8) : (e = null, i('"received"')), e !== null ? (n = m(), n !== null ? (r = et(), r === null && (r = Ut()), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.received = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function us() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 6).toLowerCase() === "branch" ? (e = l.substr(t, 6), t += 6) : (e = null, i('"branch"')), e !== null ? (n = m(), n !== null ? (r = R(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.branch = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function fs() {
          var e, n, r, s, a;
          return s = t, l.substr(t, 5).toLowerCase() === "rport" ? (e = l.substr(t, 5), t += 5) : (e = null, i('"rport"')), e !== null ? (a = t, n = m(), n !== null ? (r = cs(), r !== null ? n = [n, r] : (n = null, t = a)) : (n = null, t = a), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e;
        }
        function cs() {
          var e, n, r, s, a, f, S;
          return f = t, S = t, e = o(), e = e !== null ? e : "", e !== null ? (n = o(), n = n !== null ? n : "", n !== null ? (r = o(), r = r !== null ? r : "", r !== null ? (s = o(), s = s !== null ? s : "", s !== null ? (a = o(), a = a !== null ? a : "", a !== null ? e = [e, n, r, s, a] : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S), e !== null && (e = function(J, te) {
            H.rport = parseInt(te.join(""));
          }(f, e)), e === null && (t = f), e;
        }
        function hs() {
          var e, n, r, s, a, f;
          return f = t, e = ds(), e !== null ? (n = u(), n !== null ? (r = R(), r !== null ? (s = u(), s !== null ? (a = _s(), a !== null ? e = [e, n, r, s, a] : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f)) : (e = null, t = f), e;
        }
        function ds() {
          var e, n;
          return n = t, l.substr(t, 3).toLowerCase() === "sip" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"SIP"')), e === null && (e = R()), e !== null && (e = function(r, s) {
            H.protocol = s;
          }(n, e)), e === null && (t = n), e;
        }
        function _s() {
          var e, n;
          return n = t, l.substr(t, 3).toLowerCase() === "udp" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"UDP"')), e === null && (l.substr(t, 3).toLowerCase() === "tcp" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"TCP"')), e === null && (l.substr(t, 3).toLowerCase() === "tls" ? (e = l.substr(t, 3), t += 3) : (e = null, i('"TLS"')), e === null && (l.substr(t, 4).toLowerCase() === "sctp" ? (e = l.substr(t, 4), t += 4) : (e = null, i('"SCTP"')), e === null && (e = R())))), e !== null && (e = function(r, s) {
            H.transport = s;
          }(n, e)), e === null && (t = n), e;
        }
        function ps() {
          var e, n, r, s, a;
          return s = t, e = vs(), e !== null ? (a = t, n = re(), n !== null ? (r = ms(), r !== null ? n = [n, r] : (n = null, t = a)) : (n = null, t = a), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = s)) : (e = null, t = s), e;
        }
        function vs() {
          var e, n;
          return n = t, e = et(), e === null && (e = xt(), e === null && (e = Dt())), e !== null && (e = function(r) {
            H.host = l.substring(t, r);
          }(n)), e === null && (t = n), e;
        }
        function ms() {
          var e, n, r, s, a, f, S;
          return f = t, S = t, e = o(), e = e !== null ? e : "", e !== null ? (n = o(), n = n !== null ? n : "", n !== null ? (r = o(), r = r !== null ? r : "", r !== null ? (s = o(), s = s !== null ? s : "", s !== null ? (a = o(), a = a !== null ? a : "", a !== null ? e = [e, n, r, s, a] : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S)) : (e = null, t = S), e !== null && (e = function(J, te) {
            H.port = parseInt(te.join(""));
          }(f, e)), e === null && (t = f), e;
        }
        function Jt() {
          var e, n, r, s, a;
          return s = t, a = t, e = o(), e !== null ? (n = o(), n = n !== null ? n : "", n !== null ? (r = o(), r = r !== null ? r : "", r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            return parseInt(S.join(""));
          }(s, e)), e === null && (t = s), e;
        }
        function el() {
          var e;
          return e = Wt(), e;
        }
        function tl() {
          var e, n, r, s, a, f;
          if (a = t, e = gs(), e !== null) {
            for (n = [], f = t, r = Z(), r !== null ? (s = Xt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = Z(), r !== null ? (s = Xt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function gs() {
          var e, n;
          return n = t, e = Ke(), e !== null && (e = function(r, s) {
            H.expires = s;
          }(n, e)), e === null && (t = n), e;
        }
        function Xt() {
          var e;
          return e = ys(), e === null && (e = Ae()), e;
        }
        function ys() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 9).toLowerCase() === "refresher" ? (e = l.substr(t, 9), t += 9) : (e = null, i('"refresher"')), e !== null ? (n = m(), n !== null ? (l.substr(t, 3).toLowerCase() === "uac" ? (r = l.substr(t, 3), t += 3) : (r = null, i('"uac"')), r === null && (l.substr(t, 3).toLowerCase() === "uas" ? (r = l.substr(t, 3), t += 3) : (r = null, i('"uas"'))), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.refresher = S.toLowerCase();
          }(s, e[2])), e === null && (t = s), e;
        }
        function nl() {
          var e, n, r, s;
          return s = t, e = R(), e !== null ? (n = K(), n !== null ? (r = Ts(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function Ts() {
          var e, n;
          for (e = [], n = D(), n === null && (n = d(), n === null && (n = C())); n !== null; )
            e.push(n), n = D(), n === null && (n = d(), n === null && (n = C()));
          return e;
        }
        function rl() {
          var e, n;
          for (e = [], n = j(); n !== null; )
            e.push(n), n = j();
          return e;
        }
        function sl() {
          var e, n, r;
          return r = t, l.substr(t, 5) === "uuid:" ? (e = "uuid:", t += 5) : (e = null, i('"uuid:"')), e !== null ? (n = Ss(), n !== null ? e = [e, n] : (e = null, t = r)) : (e = null, t = r), e;
        }
        function Ss() {
          var e, n, r, s, a, f, S, J, te, fe, ge;
          return fe = t, ge = t, e = Cs(), e !== null ? (l.charCodeAt(t) === 45 ? (n = "-", t++) : (n = null, i('"-"')), n !== null ? (r = Le(), r !== null ? (l.charCodeAt(t) === 45 ? (s = "-", t++) : (s = null, i('"-"')), s !== null ? (a = Le(), a !== null ? (l.charCodeAt(t) === 45 ? (f = "-", t++) : (f = null, i('"-"')), f !== null ? (S = Le(), S !== null ? (l.charCodeAt(t) === 45 ? (J = "-", t++) : (J = null, i('"-"')), J !== null ? (te = Es(), te !== null ? e = [e, n, r, s, a, f, S, J, te] : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge)) : (e = null, t = ge), e !== null && (e = function(Pe, Rt) {
            H = l.substring(t + 5, Pe);
          }(fe, e[0])), e === null && (t = fe), e;
        }
        function Le() {
          var e, n, r, s, a;
          return a = t, e = p(), e !== null ? (n = p(), n !== null ? (r = p(), r !== null ? (s = p(), s !== null ? e = [e, n, r, s] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e;
        }
        function Cs() {
          var e, n, r;
          return r = t, e = Le(), e !== null ? (n = Le(), n !== null ? e = [e, n] : (e = null, t = r)) : (e = null, t = r), e;
        }
        function Es() {
          var e, n, r, s;
          return s = t, e = Le(), e !== null ? (n = Le(), n !== null ? (r = Le(), r !== null ? e = [e, n, r] : (e = null, t = s)) : (e = null, t = s)) : (e = null, t = s), e;
        }
        function il() {
          var e, n, r, s, a, f, S;
          if (a = t, f = t, e = _e(), e === null && (e = We()), e !== null) {
            for (n = [], S = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S); r !== null; )
              n.push(r), S = t, r = Z(), r !== null ? (s = Ae(), s !== null ? r = [r, s] : (r = null, t = S)) : (r = null, t = S);
            n !== null ? e = [e, n] : (e = null, t = f);
          } else
            e = null, t = f;
          return e !== null && (e = function(J) {
            try {
              H = new Je(H.uri, H.display_name, H.params);
            } catch {
              H = -1;
            }
          }()), e === null && (t = a), e;
        }
        function ll() {
          var e, n, r, s, a, f;
          if (a = t, e = As(), e !== null) {
            for (n = [], f = t, r = Z(), r !== null ? (s = Qt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f); r !== null; )
              n.push(r), f = t, r = Z(), r !== null ? (s = Qt(), s !== null ? r = [r, s] : (r = null, t = f)) : (r = null, t = f);
            n !== null ? e = [e, n] : (e = null, t = a);
          } else
            e = null, t = a;
          return e;
        }
        function As() {
          var e, n, r, s, a, f;
          return s = t, a = t, e = V(), e !== null ? (f = t, l.charCodeAt(t) === 64 ? (n = "@", t++) : (n = null, i('"@"')), n !== null ? (r = V(), r !== null ? n = [n, r] : (n = null, t = f)) : (n = null, t = f), n = n !== null ? n : "", n !== null ? e = [e, n] : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(S) {
            H.call_id = l.substring(t, S);
          }(s)), e === null && (t = s), e;
        }
        function Qt() {
          var e;
          return e = bs(), e === null && (e = Rs(), e === null && (e = ws(), e === null && (e = Ae()))), e;
        }
        function bs() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 6) === "to-tag" ? (e = "to-tag", t += 6) : (e = null, i('"to-tag"')), e !== null ? (n = m(), n !== null ? (r = R(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.to_tag = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function Rs() {
          var e, n, r, s, a;
          return s = t, a = t, l.substr(t, 8) === "from-tag" ? (e = "from-tag", t += 8) : (e = null, i('"from-tag"')), e !== null ? (n = m(), n !== null ? (r = R(), r !== null ? e = [e, n, r] : (e = null, t = a)) : (e = null, t = a)) : (e = null, t = a), e !== null && (e = function(f, S) {
            H.from_tag = S;
          }(s, e[2])), e === null && (t = s), e;
        }
        function ws() {
          var e, n;
          return n = t, l.substr(t, 10) === "early-only" ? (e = "early-only", t += 10) : (e = null, i('"early-only"')), e !== null && (e = function(r) {
            H.early_only = !0;
          }()), e === null && (t = n), e;
        }
        function al(e) {
          e.sort();
          for (var n = null, r = [], s = 0; s < e.length; s++)
            e[s] !== n && (r.push(e[s]), n = e[s]);
          return r;
        }
        function ol() {
          for (var e = 1, n = 1, r = !1, s = 0; s < Math.max(t, b); s++) {
            var a = l.charAt(s);
            a === `
` ? (r || e++, n = 1, r = !1) : a === "\r" || a === "\u2028" || a === "\u2029" ? (e++, n = 1, r = !0) : (n++, r = !1);
          }
          return {
            line: e,
            column: n
          };
        }
        var Is = Ve(), Je = Bn(), H = {}, ul = F[X]();
        if (ul === null || t !== l.length) {
          var Zt = Math.max(t, b), fl = Zt < l.length ? l.charAt(Zt) : null, Os = ol();
          return new this.SyntaxError(al(E), fl, Zt, Os.line, Os.column), -1;
        }
        return H;
      },
      /* Returns the parser source code. */
      toSource: function() {
        return this._source;
      }
    };
    return y.SyntaxError = function(M, l, X, F, t) {
      function b(E, i) {
        var c, o;
        switch (E.length) {
          case 0:
            c = "end of input";
            break;
          case 1:
            c = E[0];
            break;
          default:
            c = E.slice(0, E.length - 1).join(", ") + " or " + E[E.length - 1];
        }
        return o = i ? U(i) : "end of input", "Expected " + c + " but " + o + " found.";
      }
      this.name = "SyntaxError", this.expected = M, this.found = l, this.message = b(M, l), this.offset = X, this.line = F, this.column = t;
    }, y.SyntaxError.prototype = Error.prototype, y;
  }()), an;
}
var on, Us;
function Ve() {
  if (Us) return on;
  Us = 1;
  function U(i, c) {
    var o;
    if (typeof Symbol > "u" || i[Symbol.iterator] == null) {
      if (Array.isArray(i) || (o = y(i)) || c) {
        o && (i = o);
        var h = 0, p = function() {
        };
        return { s: p, n: function() {
          return h >= i.length ? { done: !0 } : { done: !1, value: i[h++] };
        }, e: function(k) {
          throw k;
        }, f: p };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var W = !0, j = !1, P;
    return { s: function() {
      o = i[Symbol.iterator]();
    }, n: function() {
      var k = o.next();
      return W = k.done, k;
    }, e: function(k) {
      j = !0, P = k;
    }, f: function() {
      try {
        !W && o.return != null && o.return();
      } finally {
        if (j) throw P;
      }
    } };
  }
  function y(i, c) {
    if (i) {
      if (typeof i == "string") return M(i, c);
      var o = Object.prototype.toString.call(i).slice(8, -1);
      if (o === "Object" && i.constructor && (o = i.constructor.name), o === "Map" || o === "Set") return Array.from(i);
      if (o === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)) return M(i, c);
    }
  }
  function M(i, c) {
    (c == null || c > i.length) && (c = i.length);
    for (var o = 0, h = new Array(c); o < c; o++)
      h[o] = i[o];
    return h;
  }
  function l(i, c) {
    if (!(i instanceof c))
      throw new TypeError("Cannot call a class as a function");
  }
  function X(i, c) {
    for (var o = 0; o < c.length; o++) {
      var h = c[o];
      h.enumerable = h.enumerable || !1, h.configurable = !0, "value" in h && (h.writable = !0), Object.defineProperty(i, h.key, h);
    }
  }
  function F(i, c, o) {
    return c && X(i.prototype, c), o && X(i, o), i;
  }
  var t = Re(), b = Oe(), E = Ue();
  return on = /* @__PURE__ */ function() {
    F(i, null, [{
      key: "parse",
      /**
        * Parse the given string and returns a JsSIP.URI instance or undefined if
        * it is an invalid URI.
        */
      value: function(o) {
        if (o = E.parse(o, "SIP_URI"), o !== -1)
          return o;
      }
    }]);
    function i(c, o, h, p) {
      var W = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {}, j = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
      if (l(this, i), !h)
        throw new TypeError('missing or invalid "host" parameter');
      this._parameters = {}, this._headers = {}, this._scheme = c || t.SIP, this._user = o, this._host = h, this._port = p;
      for (var P in W)
        Object.prototype.hasOwnProperty.call(W, P) && this.setParam(P, W[P]);
      for (var g in j)
        Object.prototype.hasOwnProperty.call(j, g) && this.setHeader(g, j[g]);
    }
    return F(i, [{
      key: "setParam",
      value: function(o, h) {
        o && (this._parameters[o.toLowerCase()] = typeof h > "u" || h === null ? null : h.toString());
      }
    }, {
      key: "getParam",
      value: function(o) {
        if (o)
          return this._parameters[o.toLowerCase()];
      }
    }, {
      key: "hasParam",
      value: function(o) {
        if (o)
          return this._parameters.hasOwnProperty(o.toLowerCase()) && !0 || !1;
      }
    }, {
      key: "deleteParam",
      value: function(o) {
        if (o = o.toLowerCase(), this._parameters.hasOwnProperty(o)) {
          var h = this._parameters[o];
          return delete this._parameters[o], h;
        }
      }
    }, {
      key: "clearParams",
      value: function() {
        this._parameters = {};
      }
    }, {
      key: "setHeader",
      value: function(o, h) {
        this._headers[b.headerize(o)] = Array.isArray(h) ? h : [h];
      }
    }, {
      key: "getHeader",
      value: function(o) {
        if (o)
          return this._headers[b.headerize(o)];
      }
    }, {
      key: "hasHeader",
      value: function(o) {
        if (o)
          return this._headers.hasOwnProperty(b.headerize(o)) && !0 || !1;
      }
    }, {
      key: "deleteHeader",
      value: function(o) {
        if (o = b.headerize(o), this._headers.hasOwnProperty(o)) {
          var h = this._headers[o];
          return delete this._headers[o], h;
        }
      }
    }, {
      key: "clearHeaders",
      value: function() {
        this._headers = {};
      }
    }, {
      key: "clone",
      value: function() {
        return new i(this._scheme, this._user, this._host, this._port, JSON.parse(JSON.stringify(this._parameters)), JSON.parse(JSON.stringify(this._headers)));
      }
    }, {
      key: "toString",
      value: function() {
        var o = [], h = "".concat(this._scheme, ":");
        this._user && (h += "".concat(b.escapeUser(this._user), "@")), h += this._host, (this._port || this._port === 0) && (h += ":".concat(this._port));
        for (var p in this._parameters)
          Object.prototype.hasOwnProperty.call(this._parameters, p) && (h += ";".concat(p), this._parameters[p] !== null && (h += "=".concat(this._parameters[p])));
        for (var W in this._headers)
          if (Object.prototype.hasOwnProperty.call(this._headers, W)) {
            var j = U(this._headers[W]), P;
            try {
              for (j.s(); !(P = j.n()).done; ) {
                var g = P.value;
                o.push("".concat(W, "=").concat(g));
              }
            } catch (k) {
              j.e(k);
            } finally {
              j.f();
            }
          }
        return o.length > 0 && (h += "?".concat(o.join("&"))), h;
      }
    }, {
      key: "toAor",
      value: function(o) {
        var h = "".concat(this._scheme, ":");
        return this._user && (h += "".concat(b.escapeUser(this._user), "@")), h += this._host, o && (this._port || this._port === 0) && (h += ":".concat(this._port)), h;
      }
    }, {
      key: "scheme",
      get: function() {
        return this._scheme;
      },
      set: function(o) {
        this._scheme = o.toLowerCase();
      }
    }, {
      key: "user",
      get: function() {
        return this._user;
      },
      set: function(o) {
        this._user = o;
      }
    }, {
      key: "host",
      get: function() {
        return this._host;
      },
      set: function(o) {
        this._host = o.toLowerCase();
      }
    }, {
      key: "port",
      get: function() {
        return this._port;
      },
      set: function(o) {
        this._port = o === 0 ? o : parseInt(o, 10) || null;
      }
    }]), i;
  }(), on;
}
var Ms;
function Oe() {
  if (Ms) return Ee;
  Ms = 1;
  function U(c) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(h) {
      return typeof h;
    } : U = function(h) {
      return h && typeof Symbol == "function" && h.constructor === Symbol && h !== Symbol.prototype ? "symbol" : typeof h;
    }, U(c);
  }
  function y(c, o) {
    var h;
    if (typeof Symbol > "u" || c[Symbol.iterator] == null) {
      if (Array.isArray(c) || (h = M(c)) || o) {
        h && (c = h);
        var p = 0, W = function() {
        };
        return { s: W, n: function() {
          return p >= c.length ? { done: !0 } : { done: !1, value: c[p++] };
        }, e: function(N) {
          throw N;
        }, f: W };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var j = !0, P = !1, g;
    return { s: function() {
      h = c[Symbol.iterator]();
    }, n: function() {
      var N = h.next();
      return j = N.done, N;
    }, e: function(N) {
      P = !0, g = N;
    }, f: function() {
      try {
        !j && h.return != null && h.return();
      } finally {
        if (P) throw g;
      }
    } };
  }
  function M(c, o) {
    if (c) {
      if (typeof c == "string") return l(c, o);
      var h = Object.prototype.toString.call(c).slice(8, -1);
      if (h === "Object" && c.constructor && (h = c.constructor.name), h === "Map" || h === "Set") return Array.from(c);
      if (h === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h)) return l(c, o);
    }
  }
  function l(c, o) {
    (o == null || o > c.length) && (o = c.length);
    for (var h = 0, p = new Array(o); h < o; h++)
      p[h] = c[h];
    return p;
  }
  var X = Re(), F = Ve(), t = Ue();
  Ee.str_utf8_length = function(c) {
    return unescape(encodeURIComponent(c)).length;
  };
  var b = Ee.isFunction = function(c) {
    return c !== void 0 ? Object.prototype.toString.call(c) === "[object Function]" : !1;
  };
  Ee.isString = function(c) {
    return c !== void 0 ? Object.prototype.toString.call(c) === "[object String]" : !1;
  }, Ee.isDecimal = function(c) {
    return !isNaN(c) && parseFloat(c) === parseInt(c, 10);
  }, Ee.isEmpty = function(c) {
    return c === null || c === "" || c === void 0 || Array.isArray(c) && c.length === 0 || typeof c == "number" && isNaN(c);
  }, Ee.hasMethods = function(c) {
    for (var o = arguments.length, h = new Array(o > 1 ? o - 1 : 0), p = 1; p < o; p++)
      h[p - 1] = arguments[p];
    for (var W = 0, j = h; W < j.length; W++) {
      var P = j[W];
      if (b(c[P]))
        return !1;
    }
    return !0;
  };
  var E = Ee.createRandomToken = function(c) {
    var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 32, h, p, W = "";
    for (h = 0; h < c; h++)
      p = Math.random() * o | 0, W += p.toString(o);
    return W;
  };
  Ee.newTag = function() {
    return E(10);
  }, Ee.newUUID = function() {
    var c = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(o) {
      var h = Math.random() * 16 | 0, p = o === "x" ? h : h & 3 | 8;
      return p.toString(16);
    });
    return c;
  }, Ee.hostType = function(c) {
    if (c) {
      if (c = t.parse(c, "host"), c !== -1)
        return c.host_type;
    } else
      return;
  };
  var i = Ee.escapeUser = function(c) {
    return encodeURIComponent(decodeURIComponent(c)).replace(/%3A/ig, ":").replace(/%2B/ig, "+").replace(/%3F/ig, "?").replace(/%2F/ig, "/");
  };
  return Ee.normalizeTarget = function(c, o) {
    if (c) {
      if (c instanceof F)
        return c;
      if (typeof c == "string") {
        var h = c.split("@"), p, W;
        switch (h.length) {
          case 1:
            if (!o)
              return;
            p = c, W = o;
            break;
          case 2:
            p = h[0], W = h[1];
            break;
          default:
            p = h.slice(0, h.length - 1).join("@"), W = h[h.length - 1];
        }
        p = p.replace(/^(sips?|tel):/i, ""), /^[-.()]*\+?[0-9\-.()]+$/.test(p) && (p = p.replace(/[-.()]/g, "")), c = "".concat(X.SIP, ":").concat(i(p), "@").concat(W);
        var j;
        return (j = F.parse(c)) ? j : void 0;
      } else
        return;
    } else return;
  }, Ee.headerize = function(c) {
    var o = {
      "Call-Id": "Call-ID",
      Cseq: "CSeq",
      "Www-Authenticate": "WWW-Authenticate"
    }, h = c.toLowerCase().replace(/_/g, "-").split("-"), p = "", W = h.length, j;
    for (j = 0; j < W; j++)
      j !== 0 && (p += "-"), p += h[j].charAt(0).toUpperCase() + h[j].substring(1);
    return o[p] && (p = o[p]), p;
  }, Ee.sipErrorCause = function(c) {
    for (var o in X.SIP_ERROR_CAUSES)
      if (X.SIP_ERROR_CAUSES[o].indexOf(c) !== -1)
        return X.causes[o];
    return X.causes.SIP_FAILURE_CODE;
  }, Ee.getRandomTestNetIP = function() {
    function c(o, h) {
      return Math.floor(Math.random() * (h - o + 1) + o);
    }
    return "192.0.2.".concat(c(1, 254));
  }, Ee.calculateMD5 = function(c) {
    function o(ue, ae) {
      return ue << ae | ue >>> 32 - ae;
    }
    function h(ue, ae) {
      var ce = ue & 2147483648, _e = ae & 2147483648, ve = ue & 1073741824, Se = ae & 1073741824, me = (ue & 1073741823) + (ae & 1073741823);
      return ve & Se ? me ^ 2147483648 ^ ce ^ _e : ve | Se ? me & 1073741824 ? me ^ 3221225472 ^ ce ^ _e : me ^ 1073741824 ^ ce ^ _e : me ^ ce ^ _e;
    }
    function p(ue, ae, ce) {
      return ue & ae | ~ue & ce;
    }
    function W(ue, ae, ce) {
      return ue & ce | ae & ~ce;
    }
    function j(ue, ae, ce) {
      return ue ^ ae ^ ce;
    }
    function P(ue, ae, ce) {
      return ae ^ (ue | ~ce);
    }
    function g(ue, ae, ce, _e, ve, Se, me) {
      return ue = h(ue, h(h(p(ae, ce, _e), ve), me)), h(o(ue, Se), ae);
    }
    function k(ue, ae, ce, _e, ve, Se, me) {
      return ue = h(ue, h(h(W(ae, ce, _e), ve), me)), h(o(ue, Se), ae);
    }
    function N(ue, ae, ce, _e, ve, Se, me) {
      return ue = h(ue, h(h(j(ae, ce, _e), ve), me)), h(o(ue, Se), ae);
    }
    function T(ue, ae, ce, _e, ve, Se, me) {
      return ue = h(ue, h(h(P(ae, ce, _e), ve), me)), h(o(ue, Se), ae);
    }
    function v(ue) {
      for (var ae, ce = ue.length, _e = ce + 8, ve = (_e - _e % 64) / 64, Se = (ve + 1) * 16, me = new Array(Se - 1), Me = 0, we = 0; we < ce; )
        ae = (we - we % 4) / 4, Me = we % 4 * 8, me[ae] = me[ae] | ue.charCodeAt(we) << Me, we++;
      return ae = (we - we % 4) / 4, Me = we % 4 * 8, me[ae] = me[ae] | 128 << Me, me[Se - 2] = ce << 3, me[Se - 1] = ce >>> 29, me;
    }
    function w(ue) {
      var ae = "", ce = "", _e, ve;
      for (ve = 0; ve <= 3; ve++)
        _e = ue >>> ve * 8 & 255, ce = "0".concat(_e.toString(16)), ae = ae + ce.substr(ce.length - 2, 2);
      return ae;
    }
    function I(ue) {
      for (var ae = "", ce = 0; ce < ue.length; ce++) {
        var _e = ue.charCodeAt(ce);
        _e < 128 ? ae += String.fromCharCode(_e) : _e > 127 && _e < 2048 ? (ae += String.fromCharCode(_e >> 6 | 192), ae += String.fromCharCode(_e & 63 | 128)) : (ae += String.fromCharCode(_e >> 12 | 224), ae += String.fromCharCode(_e >> 6 & 63 | 128), ae += String.fromCharCode(_e & 63 | 128));
      }
      return ae;
    }
    var C = [], O, K, Y, D, B, d, _, R, A, G = 7, V = 12, x = 17, u = 22, m = 5, L = 9, q = 14, $ = 20, z = 4, ee = 11, Z = 16, re = 23, se = 6, ne = 10, he = 15, pe = 21;
    for (c = I(c), C = v(c), d = 1732584193, _ = 4023233417, R = 2562383102, A = 271733878, O = 0; O < C.length; O += 16)
      K = d, Y = _, D = R, B = A, d = g(d, _, R, A, C[O + 0], G, 3614090360), A = g(A, d, _, R, C[O + 1], V, 3905402710), R = g(R, A, d, _, C[O + 2], x, 606105819), _ = g(_, R, A, d, C[O + 3], u, 3250441966), d = g(d, _, R, A, C[O + 4], G, 4118548399), A = g(A, d, _, R, C[O + 5], V, 1200080426), R = g(R, A, d, _, C[O + 6], x, 2821735955), _ = g(_, R, A, d, C[O + 7], u, 4249261313), d = g(d, _, R, A, C[O + 8], G, 1770035416), A = g(A, d, _, R, C[O + 9], V, 2336552879), R = g(R, A, d, _, C[O + 10], x, 4294925233), _ = g(_, R, A, d, C[O + 11], u, 2304563134), d = g(d, _, R, A, C[O + 12], G, 1804603682), A = g(A, d, _, R, C[O + 13], V, 4254626195), R = g(R, A, d, _, C[O + 14], x, 2792965006), _ = g(_, R, A, d, C[O + 15], u, 1236535329), d = k(d, _, R, A, C[O + 1], m, 4129170786), A = k(A, d, _, R, C[O + 6], L, 3225465664), R = k(R, A, d, _, C[O + 11], q, 643717713), _ = k(_, R, A, d, C[O + 0], $, 3921069994), d = k(d, _, R, A, C[O + 5], m, 3593408605), A = k(A, d, _, R, C[O + 10], L, 38016083), R = k(R, A, d, _, C[O + 15], q, 3634488961), _ = k(_, R, A, d, C[O + 4], $, 3889429448), d = k(d, _, R, A, C[O + 9], m, 568446438), A = k(A, d, _, R, C[O + 14], L, 3275163606), R = k(R, A, d, _, C[O + 3], q, 4107603335), _ = k(_, R, A, d, C[O + 8], $, 1163531501), d = k(d, _, R, A, C[O + 13], m, 2850285829), A = k(A, d, _, R, C[O + 2], L, 4243563512), R = k(R, A, d, _, C[O + 7], q, 1735328473), _ = k(_, R, A, d, C[O + 12], $, 2368359562), d = N(d, _, R, A, C[O + 5], z, 4294588738), A = N(A, d, _, R, C[O + 8], ee, 2272392833), R = N(R, A, d, _, C[O + 11], Z, 1839030562), _ = N(_, R, A, d, C[O + 14], re, 4259657740), d = N(d, _, R, A, C[O + 1], z, 2763975236), A = N(A, d, _, R, C[O + 4], ee, 1272893353), R = N(R, A, d, _, C[O + 7], Z, 4139469664), _ = N(_, R, A, d, C[O + 10], re, 3200236656), d = N(d, _, R, A, C[O + 13], z, 681279174), A = N(A, d, _, R, C[O + 0], ee, 3936430074), R = N(R, A, d, _, C[O + 3], Z, 3572445317), _ = N(_, R, A, d, C[O + 6], re, 76029189), d = N(d, _, R, A, C[O + 9], z, 3654602809), A = N(A, d, _, R, C[O + 12], ee, 3873151461), R = N(R, A, d, _, C[O + 15], Z, 530742520), _ = N(_, R, A, d, C[O + 2], re, 3299628645), d = T(d, _, R, A, C[O + 0], se, 4096336452), A = T(A, d, _, R, C[O + 7], ne, 1126891415), R = T(R, A, d, _, C[O + 14], he, 2878612391), _ = T(_, R, A, d, C[O + 5], pe, 4237533241), d = T(d, _, R, A, C[O + 12], se, 1700485571), A = T(A, d, _, R, C[O + 3], ne, 2399980690), R = T(R, A, d, _, C[O + 10], he, 4293915773), _ = T(_, R, A, d, C[O + 1], pe, 2240044497), d = T(d, _, R, A, C[O + 8], se, 1873313359), A = T(A, d, _, R, C[O + 15], ne, 4264355552), R = T(R, A, d, _, C[O + 6], he, 2734768916), _ = T(_, R, A, d, C[O + 13], pe, 1309151649), d = T(d, _, R, A, C[O + 4], se, 4149444226), A = T(A, d, _, R, C[O + 11], ne, 3174756917), R = T(R, A, d, _, C[O + 2], he, 718787259), _ = T(_, R, A, d, C[O + 9], pe, 3951481745), d = h(d, K), _ = h(_, Y), R = h(R, D), A = h(A, B);
    var Te = w(d) + w(_) + w(R) + w(A);
    return Te.toLowerCase();
  }, Ee.closeMediaStream = function(c) {
    if (c)
      try {
        var o;
        if (c.getTracks) {
          o = c.getTracks();
          var h = y(o), p;
          try {
            for (h.s(); !(p = h.n()).done; ) {
              var W = p.value;
              W.stop();
            }
          } catch (v) {
            h.e(v);
          } finally {
            h.f();
          }
        } else {
          o = c.getAudioTracks();
          var j = y(o), P;
          try {
            for (j.s(); !(P = j.n()).done; ) {
              var g = P.value;
              g.stop();
            }
          } catch (v) {
            j.e(v);
          } finally {
            j.f();
          }
          o = c.getVideoTracks();
          var k = y(o), N;
          try {
            for (k.s(); !(N = k.n()).done; ) {
              var T = N.value;
              T.stop();
            }
          } catch (v) {
            k.e(v);
          } finally {
            k.f();
          }
        }
      } catch {
        (typeof c.stop == "function" || U(c.stop) === "object") && c.stop();
      }
  }, Ee.cloneArray = function(c) {
    return c && c.slice() || [];
  }, Ee.cloneObject = function(c) {
    var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
    return c && Object.assign({}, c) || o;
  }, Ee;
}
var wt = { exports: {} }, Ls;
function Be() {
  if (Ls) return wt.exports;
  Ls = 1;
  var U = typeof Reflect == "object" ? Reflect : null, y = U && typeof U.apply == "function" ? U.apply : function(v, w, I) {
    return Function.prototype.apply.call(v, w, I);
  }, M;
  U && typeof U.ownKeys == "function" ? M = U.ownKeys : Object.getOwnPropertySymbols ? M = function(v) {
    return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v));
  } : M = function(v) {
    return Object.getOwnPropertyNames(v);
  };
  function l(T) {
    console && console.warn && console.warn(T);
  }
  var X = Number.isNaN || function(v) {
    return v !== v;
  };
  function F() {
    F.init.call(this);
  }
  wt.exports = F, wt.exports.once = g, F.EventEmitter = F, F.prototype._events = void 0, F.prototype._eventsCount = 0, F.prototype._maxListeners = void 0;
  var t = 10;
  function b(T) {
    if (typeof T != "function")
      throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof T);
  }
  Object.defineProperty(F, "defaultMaxListeners", {
    enumerable: !0,
    get: function() {
      return t;
    },
    set: function(T) {
      if (typeof T != "number" || T < 0 || X(T))
        throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + T + ".");
      t = T;
    }
  }), F.init = function() {
    (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
  }, F.prototype.setMaxListeners = function(v) {
    if (typeof v != "number" || v < 0 || X(v))
      throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + v + ".");
    return this._maxListeners = v, this;
  };
  function E(T) {
    return T._maxListeners === void 0 ? F.defaultMaxListeners : T._maxListeners;
  }
  F.prototype.getMaxListeners = function() {
    return E(this);
  }, F.prototype.emit = function(v) {
    for (var w = [], I = 1; I < arguments.length; I++) w.push(arguments[I]);
    var C = v === "error", O = this._events;
    if (O !== void 0)
      C = C && O.error === void 0;
    else if (!C)
      return !1;
    if (C) {
      var K;
      if (w.length > 0 && (K = w[0]), K instanceof Error)
        throw K;
      var Y = new Error("Unhandled error." + (K ? " (" + K.message + ")" : ""));
      throw Y.context = K, Y;
    }
    var D = O[v];
    if (D === void 0)
      return !1;
    if (typeof D == "function")
      y(D, this, w);
    else
      for (var B = D.length, d = W(D, B), I = 0; I < B; ++I)
        y(d[I], this, w);
    return !0;
  };
  function i(T, v, w, I) {
    var C, O, K;
    if (b(w), O = T._events, O === void 0 ? (O = T._events = /* @__PURE__ */ Object.create(null), T._eventsCount = 0) : (O.newListener !== void 0 && (T.emit(
      "newListener",
      v,
      w.listener ? w.listener : w
    ), O = T._events), K = O[v]), K === void 0)
      K = O[v] = w, ++T._eventsCount;
    else if (typeof K == "function" ? K = O[v] = I ? [w, K] : [K, w] : I ? K.unshift(w) : K.push(w), C = E(T), C > 0 && K.length > C && !K.warned) {
      K.warned = !0;
      var Y = new Error("Possible EventEmitter memory leak detected. " + K.length + " " + String(v) + " listeners added. Use emitter.setMaxListeners() to increase limit");
      Y.name = "MaxListenersExceededWarning", Y.emitter = T, Y.type = v, Y.count = K.length, l(Y);
    }
    return T;
  }
  F.prototype.addListener = function(v, w) {
    return i(this, v, w, !1);
  }, F.prototype.on = F.prototype.addListener, F.prototype.prependListener = function(v, w) {
    return i(this, v, w, !0);
  };
  function c() {
    if (!this.fired)
      return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
  }
  function o(T, v, w) {
    var I = { fired: !1, wrapFn: void 0, target: T, type: v, listener: w }, C = c.bind(I);
    return C.listener = w, I.wrapFn = C, C;
  }
  F.prototype.once = function(v, w) {
    return b(w), this.on(v, o(this, v, w)), this;
  }, F.prototype.prependOnceListener = function(v, w) {
    return b(w), this.prependListener(v, o(this, v, w)), this;
  }, F.prototype.removeListener = function(v, w) {
    var I, C, O, K, Y;
    if (b(w), C = this._events, C === void 0)
      return this;
    if (I = C[v], I === void 0)
      return this;
    if (I === w || I.listener === w)
      --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete C[v], C.removeListener && this.emit("removeListener", v, I.listener || w));
    else if (typeof I != "function") {
      for (O = -1, K = I.length - 1; K >= 0; K--)
        if (I[K] === w || I[K].listener === w) {
          Y = I[K].listener, O = K;
          break;
        }
      if (O < 0)
        return this;
      O === 0 ? I.shift() : j(I, O), I.length === 1 && (C[v] = I[0]), C.removeListener !== void 0 && this.emit("removeListener", v, Y || w);
    }
    return this;
  }, F.prototype.off = F.prototype.removeListener, F.prototype.removeAllListeners = function(v) {
    var w, I, C;
    if (I = this._events, I === void 0)
      return this;
    if (I.removeListener === void 0)
      return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : I[v] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete I[v]), this;
    if (arguments.length === 0) {
      var O = Object.keys(I), K;
      for (C = 0; C < O.length; ++C)
        K = O[C], K !== "removeListener" && this.removeAllListeners(K);
      return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
    }
    if (w = I[v], typeof w == "function")
      this.removeListener(v, w);
    else if (w !== void 0)
      for (C = w.length - 1; C >= 0; C--)
        this.removeListener(v, w[C]);
    return this;
  };
  function h(T, v, w) {
    var I = T._events;
    if (I === void 0)
      return [];
    var C = I[v];
    return C === void 0 ? [] : typeof C == "function" ? w ? [C.listener || C] : [C] : w ? P(C) : W(C, C.length);
  }
  F.prototype.listeners = function(v) {
    return h(this, v, !0);
  }, F.prototype.rawListeners = function(v) {
    return h(this, v, !1);
  }, F.listenerCount = function(T, v) {
    return typeof T.listenerCount == "function" ? T.listenerCount(v) : p.call(T, v);
  }, F.prototype.listenerCount = p;
  function p(T) {
    var v = this._events;
    if (v !== void 0) {
      var w = v[T];
      if (typeof w == "function")
        return 1;
      if (w !== void 0)
        return w.length;
    }
    return 0;
  }
  F.prototype.eventNames = function() {
    return this._eventsCount > 0 ? M(this._events) : [];
  };
  function W(T, v) {
    for (var w = new Array(v), I = 0; I < v; ++I)
      w[I] = T[I];
    return w;
  }
  function j(T, v) {
    for (; v + 1 < T.length; v++)
      T[v] = T[v + 1];
    T.pop();
  }
  function P(T) {
    for (var v = new Array(T.length), w = 0; w < v.length; ++w)
      v[w] = T[w].listener || T[w];
    return v;
  }
  function g(T, v) {
    return new Promise(function(w, I) {
      function C(K) {
        T.removeListener(v, O), I(K);
      }
      function O() {
        typeof T.removeListener == "function" && T.removeListener("error", C), w([].slice.call(arguments));
      }
      N(T, v, O, { once: !0 }), v !== "error" && k(T, C, { once: !0 });
    });
  }
  function k(T, v, w) {
    typeof T.on == "function" && N(T, "error", v, w);
  }
  function N(T, v, w, I) {
    if (typeof T.on == "function")
      I.once ? T.once(v, w) : T.on(v, w);
    else if (typeof T.addEventListener == "function")
      T.addEventListener(v, function C(O) {
        I.once && T.removeEventListener(v, C), w(O);
      });
    else
      throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof T);
  }
  return wt.exports;
}
var It = { exports: {} }, un, Fs;
function ml() {
  if (Fs) return un;
  Fs = 1;
  var U = 1e3, y = U * 60, M = y * 60, l = M * 24, X = l * 7, F = l * 365.25;
  un = function(c, o) {
    o = o || {};
    var h = typeof c;
    if (h === "string" && c.length > 0)
      return t(c);
    if (h === "number" && isFinite(c))
      return o.long ? E(c) : b(c);
    throw new Error(
      "val is not a non-empty string or a valid number. val=" + JSON.stringify(c)
    );
  };
  function t(c) {
    if (c = String(c), !(c.length > 100)) {
      var o = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
        c
      );
      if (o) {
        var h = parseFloat(o[1]), p = (o[2] || "ms").toLowerCase();
        switch (p) {
          case "years":
          case "year":
          case "yrs":
          case "yr":
          case "y":
            return h * F;
          case "weeks":
          case "week":
          case "w":
            return h * X;
          case "days":
          case "day":
          case "d":
            return h * l;
          case "hours":
          case "hour":
          case "hrs":
          case "hr":
          case "h":
            return h * M;
          case "minutes":
          case "minute":
          case "mins":
          case "min":
          case "m":
            return h * y;
          case "seconds":
          case "second":
          case "secs":
          case "sec":
          case "s":
            return h * U;
          case "milliseconds":
          case "millisecond":
          case "msecs":
          case "msec":
          case "ms":
            return h;
          default:
            return;
        }
      }
    }
  }
  function b(c) {
    var o = Math.abs(c);
    return o >= l ? Math.round(c / l) + "d" : o >= M ? Math.round(c / M) + "h" : o >= y ? Math.round(c / y) + "m" : o >= U ? Math.round(c / U) + "s" : c + "ms";
  }
  function E(c) {
    var o = Math.abs(c);
    return o >= l ? i(c, o, l, "day") : o >= M ? i(c, o, M, "hour") : o >= y ? i(c, o, y, "minute") : o >= U ? i(c, o, U, "second") : c + " ms";
  }
  function i(c, o, h, p) {
    var W = o >= h * 1.5;
    return Math.round(c / h) + " " + p + (W ? "s" : "");
  }
  return un;
}
var fn, Hs;
function gl() {
  if (Hs) return fn;
  Hs = 1;
  function U(y) {
    l.debug = l, l.default = l, l.coerce = i, l.disable = b, l.enable = F, l.enabled = E, l.humanize = ml(), l.destroy = c, Object.keys(y).forEach((o) => {
      l[o] = y[o];
    }), l.names = [], l.skips = [], l.formatters = {};
    function M(o) {
      let h = 0;
      for (let p = 0; p < o.length; p++)
        h = (h << 5) - h + o.charCodeAt(p), h |= 0;
      return l.colors[Math.abs(h) % l.colors.length];
    }
    l.selectColor = M;
    function l(o) {
      let h, p = null, W, j;
      function P(...g) {
        if (!P.enabled)
          return;
        const k = P, N = Number(/* @__PURE__ */ new Date()), T = N - (h || N);
        k.diff = T, k.prev = h, k.curr = N, h = N, g[0] = l.coerce(g[0]), typeof g[0] != "string" && g.unshift("%O");
        let v = 0;
        g[0] = g[0].replace(/%([a-zA-Z%])/g, (I, C) => {
          if (I === "%%")
            return "%";
          v++;
          const O = l.formatters[C];
          if (typeof O == "function") {
            const K = g[v];
            I = O.call(k, K), g.splice(v, 1), v--;
          }
          return I;
        }), l.formatArgs.call(k, g), (k.log || l.log).apply(k, g);
      }
      return P.namespace = o, P.useColors = l.useColors(), P.color = l.selectColor(o), P.extend = X, P.destroy = l.destroy, Object.defineProperty(P, "enabled", {
        enumerable: !0,
        configurable: !1,
        get: () => p !== null ? p : (W !== l.namespaces && (W = l.namespaces, j = l.enabled(o)), j),
        set: (g) => {
          p = g;
        }
      }), typeof l.init == "function" && l.init(P), P;
    }
    function X(o, h) {
      const p = l(this.namespace + (typeof h > "u" ? ":" : h) + o);
      return p.log = this.log, p;
    }
    function F(o) {
      l.save(o), l.namespaces = o, l.names = [], l.skips = [];
      const h = (typeof o == "string" ? o : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
      for (const p of h)
        p[0] === "-" ? l.skips.push(p.slice(1)) : l.names.push(p);
    }
    function t(o, h) {
      let p = 0, W = 0, j = -1, P = 0;
      for (; p < o.length; )
        if (W < h.length && (h[W] === o[p] || h[W] === "*"))
          h[W] === "*" ? (j = W, P = p, W++) : (p++, W++);
        else if (j !== -1)
          W = j + 1, P++, p = P;
        else
          return !1;
      for (; W < h.length && h[W] === "*"; )
        W++;
      return W === h.length;
    }
    function b() {
      const o = [
        ...l.names,
        ...l.skips.map((h) => "-" + h)
      ].join(",");
      return l.enable(""), o;
    }
    function E(o) {
      for (const h of l.skips)
        if (t(o, h))
          return !1;
      for (const h of l.names)
        if (t(o, h))
          return !0;
      return !1;
    }
    function i(o) {
      return o instanceof Error ? o.stack || o.message : o;
    }
    function c() {
      console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
    }
    return l.enable(l.load()), l;
  }
  return fn = U, fn;
}
var qs;
function Fn() {
  return qs || (qs = 1, function(U, y) {
    y.formatArgs = l, y.save = X, y.load = F, y.useColors = M, y.storage = t(), y.destroy = /* @__PURE__ */ (() => {
      let E = !1;
      return () => {
        E || (E = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
      };
    })(), y.colors = [
      "#0000CC",
      "#0000FF",
      "#0033CC",
      "#0033FF",
      "#0066CC",
      "#0066FF",
      "#0099CC",
      "#0099FF",
      "#00CC00",
      "#00CC33",
      "#00CC66",
      "#00CC99",
      "#00CCCC",
      "#00CCFF",
      "#3300CC",
      "#3300FF",
      "#3333CC",
      "#3333FF",
      "#3366CC",
      "#3366FF",
      "#3399CC",
      "#3399FF",
      "#33CC00",
      "#33CC33",
      "#33CC66",
      "#33CC99",
      "#33CCCC",
      "#33CCFF",
      "#6600CC",
      "#6600FF",
      "#6633CC",
      "#6633FF",
      "#66CC00",
      "#66CC33",
      "#9900CC",
      "#9900FF",
      "#9933CC",
      "#9933FF",
      "#99CC00",
      "#99CC33",
      "#CC0000",
      "#CC0033",
      "#CC0066",
      "#CC0099",
      "#CC00CC",
      "#CC00FF",
      "#CC3300",
      "#CC3333",
      "#CC3366",
      "#CC3399",
      "#CC33CC",
      "#CC33FF",
      "#CC6600",
      "#CC6633",
      "#CC9900",
      "#CC9933",
      "#CCCC00",
      "#CCCC33",
      "#FF0000",
      "#FF0033",
      "#FF0066",
      "#FF0099",
      "#FF00CC",
      "#FF00FF",
      "#FF3300",
      "#FF3333",
      "#FF3366",
      "#FF3399",
      "#FF33CC",
      "#FF33FF",
      "#FF6600",
      "#FF6633",
      "#FF9900",
      "#FF9933",
      "#FFCC00",
      "#FFCC33"
    ];
    function M() {
      if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs))
        return !0;
      if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))
        return !1;
      let E;
      return typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
      typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
      // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
      typeof navigator < "u" && navigator.userAgent && (E = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(E[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
      typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
    }
    function l(E) {
      if (E[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + E[0] + (this.useColors ? "%c " : " ") + "+" + U.exports.humanize(this.diff), !this.useColors)
        return;
      const i = "color: " + this.color;
      E.splice(1, 0, i, "color: inherit");
      let c = 0, o = 0;
      E[0].replace(/%[a-zA-Z%]/g, (h) => {
        h !== "%%" && (c++, h === "%c" && (o = c));
      }), E.splice(o, 0, i);
    }
    y.log = console.debug || console.log || (() => {
    });
    function X(E) {
      try {
        E ? y.storage.setItem("debug", E) : y.storage.removeItem("debug");
      } catch {
      }
    }
    function F() {
      let E;
      try {
        E = y.storage.getItem("debug") || y.storage.getItem("DEBUG");
      } catch {
      }
      return !E && typeof process < "u" && "env" in process && (E = process.env.DEBUG), E;
    }
    function t() {
      try {
        return localStorage;
      } catch {
      }
    }
    U.exports = gl()(y);
    const { formatters: b } = U.exports;
    b.j = function(E) {
      try {
        return JSON.stringify(E);
      } catch (i) {
        return "[UnexpectedJSONParseError]: " + i.message;
      }
    };
  }(It, It.exports)), It.exports;
}
var cn, js;
function Ie() {
  if (js) return cn;
  js = 1;
  function U(F, t) {
    if (!(F instanceof t))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(F, t) {
    for (var b = 0; b < t.length; b++) {
      var E = t[b];
      E.enumerable = E.enumerable || !1, E.configurable = !0, "value" in E && (E.writable = !0), Object.defineProperty(F, E.key, E);
    }
  }
  function M(F, t, b) {
    return t && y(F.prototype, t), F;
  }
  var l = Fn(), X = "JsSIP";
  return cn = /* @__PURE__ */ function() {
    function F(t) {
      U(this, F), t ? (this._debug = l.default("".concat(X, ":").concat(t)), this._warn = l.default("".concat(X, ":WARN:").concat(t)), this._error = l.default("".concat(X, ":ERROR:").concat(t))) : (this._debug = l.default(X), this._warn = l.default("".concat(X, ":WARN")), this._error = l.default("".concat(X, ":ERROR"))), this._debug.log = console.info.bind(console), this._warn.log = console.warn.bind(console), this._error.log = console.error.bind(console);
    }
    return M(F, [{
      key: "debug",
      get: function() {
        return this._debug;
      }
    }, {
      key: "warn",
      get: function() {
        return this._warn;
      }
    }, {
      key: "error",
      get: function() {
        return this._error;
      }
    }]), F;
  }(), cn;
}
var De = {}, hn = {}, dn = { exports: {} }, Gs;
function Wn() {
  if (Gs) return dn.exports;
  Gs = 1;
  var U = dn.exports = {
    v: [{
      name: "version",
      reg: /^(\d*)$/
    }],
    o: [{
      // o=- 20518 0 IN IP4 203.0.113.1
      // NB: sessionId will be a String in most cases because it is huge
      name: "origin",
      reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,
      names: ["username", "sessionId", "sessionVersion", "netType", "ipVer", "address"],
      format: "%s %s %d %s IP%d %s"
    }],
    // default parsing of these only (though some of these feel outdated)
    s: [{ name: "name" }],
    i: [{ name: "description" }],
    u: [{ name: "uri" }],
    e: [{ name: "email" }],
    p: [{ name: "phone" }],
    z: [{ name: "timezones" }],
    // TODO: this one can actually be parsed properly...
    r: [{ name: "repeats" }],
    // TODO: this one can also be parsed properly
    // k: [{}], // outdated thing ignored
    t: [{
      // t=0 0
      name: "timing",
      reg: /^(\d*) (\d*)/,
      names: ["start", "stop"],
      format: "%d %d"
    }],
    c: [{
      // c=IN IP4 10.47.197.26
      name: "connection",
      reg: /^IN IP(\d) (\S*)/,
      names: ["version", "ip"],
      format: "IN IP%d %s"
    }],
    b: [{
      // b=AS:4000
      push: "bandwidth",
      reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,
      names: ["type", "limit"],
      format: "%s:%s"
    }],
    m: [{
      // m=video 51744 RTP/AVP 126 97 98 34 31
      // NB: special - pushes to session
      // TODO: rtp/fmtp should be filtered by the payloads found here?
      reg: /^(\w*) (\d*) ([\w/]*)(?: (.*))?/,
      names: ["type", "port", "protocol", "payloads"],
      format: "%s %d %s %s"
    }],
    a: [
      {
        // a=rtpmap:110 opus/48000/2
        push: "rtp",
        reg: /^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,
        names: ["payload", "codec", "rate", "encoding"],
        format: function(y) {
          return y.encoding ? "rtpmap:%d %s/%s/%s" : y.rate ? "rtpmap:%d %s/%s" : "rtpmap:%d %s";
        }
      },
      {
        // a=fmtp:108 profile-level-id=24;object=23;bitrate=64000
        // a=fmtp:111 minptime=10; useinbandfec=1
        push: "fmtp",
        reg: /^fmtp:(\d*) ([\S| ]*)/,
        names: ["payload", "config"],
        format: "fmtp:%d %s"
      },
      {
        // a=control:streamid=0
        name: "control",
        reg: /^control:(.*)/,
        format: "control:%s"
      },
      {
        // a=rtcp:65179 IN IP4 193.84.77.194
        name: "rtcp",
        reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,
        names: ["port", "netType", "ipVer", "address"],
        format: function(y) {
          return y.address != null ? "rtcp:%d %s IP%d %s" : "rtcp:%d";
        }
      },
      {
        // a=rtcp-fb:98 trr-int 100
        push: "rtcpFbTrrInt",
        reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,
        names: ["payload", "value"],
        format: "rtcp-fb:%s trr-int %d"
      },
      {
        // a=rtcp-fb:98 nack rpsi
        push: "rtcpFb",
        reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,
        names: ["payload", "type", "subtype"],
        format: function(y) {
          return y.subtype != null ? "rtcp-fb:%s %s %s" : "rtcp-fb:%s %s";
        }
      },
      {
        // a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
        // a=extmap:1/recvonly URI-gps-string
        // a=extmap:3 urn:ietf:params:rtp-hdrext:encrypt urn:ietf:params:rtp-hdrext:smpte-tc 25@600/24
        push: "ext",
        reg: /^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,
        names: ["value", "direction", "encrypt-uri", "uri", "config"],
        format: function(y) {
          return "extmap:%d" + (y.direction ? "/%s" : "%v") + (y["encrypt-uri"] ? " %s" : "%v") + " %s" + (y.config ? " %s" : "");
        }
      },
      {
        // a=extmap-allow-mixed
        name: "extmapAllowMixed",
        reg: /^(extmap-allow-mixed)/
      },
      {
        // a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32
        push: "crypto",
        reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,
        names: ["id", "suite", "config", "sessionConfig"],
        format: function(y) {
          return y.sessionConfig != null ? "crypto:%d %s %s %s" : "crypto:%d %s %s";
        }
      },
      {
        // a=setup:actpass
        name: "setup",
        reg: /^setup:(\w*)/,
        format: "setup:%s"
      },
      {
        // a=connection:new
        name: "connectionType",
        reg: /^connection:(new|existing)/,
        format: "connection:%s"
      },
      {
        // a=mid:1
        name: "mid",
        reg: /^mid:([^\s]*)/,
        format: "mid:%s"
      },
      {
        // a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a
        name: "msid",
        reg: /^msid:(.*)/,
        format: "msid:%s"
      },
      {
        // a=ptime:20
        name: "ptime",
        reg: /^ptime:(\d*(?:\.\d*)*)/,
        format: "ptime:%d"
      },
      {
        // a=maxptime:60
        name: "maxptime",
        reg: /^maxptime:(\d*(?:\.\d*)*)/,
        format: "maxptime:%d"
      },
      {
        // a=sendrecv
        name: "direction",
        reg: /^(sendrecv|recvonly|sendonly|inactive)/
      },
      {
        // a=ice-lite
        name: "icelite",
        reg: /^(ice-lite)/
      },
      {
        // a=ice-ufrag:F7gI
        name: "iceUfrag",
        reg: /^ice-ufrag:(\S*)/,
        format: "ice-ufrag:%s"
      },
      {
        // a=ice-pwd:x9cml/YzichV2+XlhiMu8g
        name: "icePwd",
        reg: /^ice-pwd:(\S*)/,
        format: "ice-pwd:%s"
      },
      {
        // a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
        name: "fingerprint",
        reg: /^fingerprint:(\S*) (\S*)/,
        names: ["type", "hash"],
        format: "fingerprint:%s %s"
      },
      {
        // a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
        // a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0 network-id 3 network-cost 10
        // a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0 network-id 3 network-cost 10
        // a=candidate:229815620 1 tcp 1518280447 192.168.150.19 60017 typ host tcptype active generation 0 network-id 3 network-cost 10
        // a=candidate:3289912957 2 tcp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 tcptype passive generation 0 network-id 3 network-cost 10
        push: "candidates",
        reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,
        names: ["foundation", "component", "transport", "priority", "ip", "port", "type", "raddr", "rport", "tcptype", "generation", "network-id", "network-cost"],
        format: function(y) {
          var M = "candidate:%s %d %s %d %s %d typ %s";
          return M += y.raddr != null ? " raddr %s rport %d" : "%v%v", M += y.tcptype != null ? " tcptype %s" : "%v", y.generation != null && (M += " generation %d"), M += y["network-id"] != null ? " network-id %d" : "%v", M += y["network-cost"] != null ? " network-cost %d" : "%v", M;
        }
      },
      {
        // a=end-of-candidates (keep after the candidates line for readability)
        name: "endOfCandidates",
        reg: /^(end-of-candidates)/
      },
      {
        // a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...
        name: "remoteCandidates",
        reg: /^remote-candidates:(.*)/,
        format: "remote-candidates:%s"
      },
      {
        // a=ice-options:google-ice
        name: "iceOptions",
        reg: /^ice-options:(\S*)/,
        format: "ice-options:%s"
      },
      {
        // a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1
        push: "ssrcs",
        reg: /^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,
        names: ["id", "attribute", "value"],
        format: function(y) {
          var M = "ssrc:%d";
          return y.attribute != null && (M += " %s", y.value != null && (M += ":%s")), M;
        }
      },
      {
        // a=ssrc-group:FEC 1 2
        // a=ssrc-group:FEC-FR 3004364195 1080772241
        push: "ssrcGroups",
        // token-char = %x21 / %x23-27 / %x2A-2B / %x2D-2E / %x30-39 / %x41-5A / %x5E-7E
        reg: /^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,
        names: ["semantics", "ssrcs"],
        format: "ssrc-group:%s %s"
      },
      {
        // a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV
        name: "msidSemantic",
        reg: /^msid-semantic:\s?(\w*) (\S*)/,
        names: ["semantic", "token"],
        format: "msid-semantic: %s %s"
        // space after ':' is not accidental
      },
      {
        // a=group:BUNDLE audio video
        push: "groups",
        reg: /^group:(\w*) (.*)/,
        names: ["type", "mids"],
        format: "group:%s %s"
      },
      {
        // a=rtcp-mux
        name: "rtcpMux",
        reg: /^(rtcp-mux)/
      },
      {
        // a=rtcp-rsize
        name: "rtcpRsize",
        reg: /^(rtcp-rsize)/
      },
      {
        // a=sctpmap:5000 webrtc-datachannel 1024
        name: "sctpmap",
        reg: /^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,
        names: ["sctpmapNumber", "app", "maxMessageSize"],
        format: function(y) {
          return y.maxMessageSize != null ? "sctpmap:%s %s %s" : "sctpmap:%s %s";
        }
      },
      {
        // a=x-google-flag:conference
        name: "xGoogleFlag",
        reg: /^x-google-flag:([^\s]*)/,
        format: "x-google-flag:%s"
      },
      {
        // a=rid:1 send max-width=1280;max-height=720;max-fps=30;depend=0
        push: "rids",
        reg: /^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,
        names: ["id", "direction", "params"],
        format: function(y) {
          return y.params ? "rid:%s %s %s" : "rid:%s %s";
        }
      },
      {
        // a=imageattr:97 send [x=800,y=640,sar=1.1,q=0.6] [x=480,y=320] recv [x=330,y=250]
        // a=imageattr:* send [x=800,y=640] recv *
        // a=imageattr:100 recv [x=320,y=240]
        push: "imageattrs",
        reg: new RegExp(
          // a=imageattr:97
          "^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"
        ),
        names: ["pt", "dir1", "attrs1", "dir2", "attrs2"],
        format: function(y) {
          return "imageattr:%s %s %s" + (y.dir2 ? " %s %s" : "");
        }
      },
      {
        // a=simulcast:send 1,2,3;~4,~5 recv 6;~7,~8
        // a=simulcast:recv 1;4,5 send 6;7
        name: "simulcast",
        reg: new RegExp(
          // a=simulcast:
          "^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"
        ),
        names: ["dir1", "list1", "dir2", "list2"],
        format: function(y) {
          return "simulcast:%s %s" + (y.dir2 ? " %s %s" : "");
        }
      },
      {
        // old simulcast draft 03 (implemented by Firefox)
        //   https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-03
        // a=simulcast: recv pt=97;98 send pt=97
        // a=simulcast: send rid=5;6;7 paused=6,7
        name: "simulcast_03",
        reg: /^simulcast:[\s\t]+([\S+\s\t]+)$/,
        names: ["value"],
        format: "simulcast: %s"
      },
      {
        // a=framerate:25
        // a=framerate:29.97
        name: "framerate",
        reg: /^framerate:(\d+(?:$|\.\d+))/,
        format: "framerate:%s"
      },
      {
        // RFC4570
        // a=source-filter: incl IN IP4 239.5.2.31 10.1.15.5
        name: "sourceFilter",
        reg: /^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,
        names: ["filterMode", "netType", "addressTypes", "destAddress", "srcList"],
        format: "source-filter: %s %s %s %s %s"
      },
      {
        // a=bundle-only
        name: "bundleOnly",
        reg: /^(bundle-only)/
      },
      {
        // a=label:1
        name: "label",
        reg: /^label:(.+)/,
        format: "label:%s"
      },
      {
        // RFC version 26 for SCTP over DTLS
        // https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-5
        name: "sctpPort",
        reg: /^sctp-port:(\d+)$/,
        format: "sctp-port:%s"
      },
      {
        // RFC version 26 for SCTP over DTLS
        // https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-6
        name: "maxMessageSize",
        reg: /^max-message-size:(\d+)$/,
        format: "max-message-size:%s"
      },
      {
        // RFC7273
        // a=ts-refclk:ptp=IEEE1588-2008:39-A7-94-FF-FE-07-CB-D0:37
        push: "tsRefClocks",
        reg: /^ts-refclk:([^\s=]*)(?:=(\S*))?/,
        names: ["clksrc", "clksrcExt"],
        format: function(y) {
          return "ts-refclk:%s" + (y.clksrcExt != null ? "=%s" : "");
        }
      },
      {
        // RFC7273
        // a=mediaclk:direct=963214424
        name: "mediaClk",
        reg: /^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,
        names: ["id", "mediaClockName", "mediaClockValue", "rateNumerator", "rateDenominator"],
        format: function(y) {
          var M = "mediaclk:";
          return M += y.id != null ? "id=%s %s" : "%v%s", M += y.mediaClockValue != null ? "=%s" : "", M += y.rateNumerator != null ? " rate=%s" : "", M += y.rateDenominator != null ? "/%s" : "", M;
        }
      },
      {
        // a=keywds:keywords
        name: "keywords",
        reg: /^keywds:(.+)$/,
        format: "keywds:%s"
      },
      {
        // a=content:main
        name: "content",
        reg: /^content:(.+)/,
        format: "content:%s"
      },
      // BFCP https://tools.ietf.org/html/rfc4583
      {
        // a=floorctrl:c-s
        name: "bfcpFloorCtrl",
        reg: /^floorctrl:(c-only|s-only|c-s)/,
        format: "floorctrl:%s"
      },
      {
        // a=confid:1
        name: "bfcpConfId",
        reg: /^confid:(\d+)/,
        format: "confid:%s"
      },
      {
        // a=userid:1
        name: "bfcpUserId",
        reg: /^userid:(\d+)/,
        format: "userid:%s"
      },
      {
        // a=floorid:1
        name: "bfcpFloorId",
        reg: /^floorid:(.+) (?:m-stream|mstrm):(.+)/,
        names: ["id", "mStream"],
        format: "floorid:%s mstrm:%s"
      },
      {
        // any a= that we don't understand is kept verbatim on media.invalid
        push: "invalid",
        names: ["value"]
      }
    ]
  };
  return Object.keys(U).forEach(function(y) {
    var M = U[y];
    M.forEach(function(l) {
      l.reg || (l.reg = /(.*)/), l.format || (l.format = "%s");
    });
  }), dn.exports;
}
var Vs;
function yl() {
  return Vs || (Vs = 1, function(U) {
    var y = function(b) {
      return String(Number(b)) === b ? Number(b) : b;
    }, M = function(b, E, i, c) {
      if (c && !i)
        E[c] = y(b[1]);
      else
        for (var o = 0; o < i.length; o += 1)
          b[o + 1] != null && (E[i[o]] = y(b[o + 1]));
    }, l = function(b, E, i) {
      var c = b.name && b.names;
      b.push && !E[b.push] ? E[b.push] = [] : c && !E[b.name] && (E[b.name] = {});
      var o = b.push ? {} : (
        // blank object that will be pushed
        c ? E[b.name] : E
      );
      M(i.match(b.reg), o, b.names, b.name), b.push && E[b.push].push(o);
    }, X = Wn(), F = RegExp.prototype.test.bind(/^([a-z])=(.*)/);
    U.parse = function(b) {
      var E = {}, i = [], c = E;
      return b.split(/(\r\n|\r|\n)/).filter(F).forEach(function(o) {
        var h = o[0], p = o.slice(2);
        h === "m" && (i.push({ rtp: [], fmtp: [] }), c = i[i.length - 1]);
        for (var W = 0; W < (X[h] || []).length; W += 1) {
          var j = X[h][W];
          if (j.reg.test(p))
            return l(j, c, p);
        }
      }), E.media = i, E;
    };
    var t = function(b, E) {
      var i = E.split(/=(.+)/, 2);
      return i.length === 2 ? b[i[0]] = y(i[1]) : i.length === 1 && E.length > 1 && (b[i[0]] = void 0), b;
    };
    U.parseParams = function(b) {
      return b.split(/;\s?/).reduce(t, {});
    }, U.parseFmtpConfig = U.parseParams, U.parsePayloads = function(b) {
      return b.toString().split(" ").map(Number);
    }, U.parseRemoteCandidates = function(b) {
      for (var E = [], i = b.split(" ").map(y), c = 0; c < i.length; c += 3)
        E.push({
          component: i[c],
          ip: i[c + 1],
          port: i[c + 2]
        });
      return E;
    }, U.parseImageAttributes = function(b) {
      return b.split(" ").map(function(E) {
        return E.substring(1, E.length - 1).split(",").reduce(t, {});
      });
    }, U.parseSimulcastStreamList = function(b) {
      return b.split(";").map(function(E) {
        return E.split(",").map(function(i) {
          var c, o = !1;
          return i[0] !== "~" ? c = y(i) : (c = y(i.substring(1, i.length)), o = !0), {
            scid: c,
            paused: o
          };
        });
      });
    };
  }(hn)), hn;
}
var _n, Bs;
function Tl() {
  if (Bs) return _n;
  Bs = 1;
  var U = Wn(), y = /%[sdv%]/g, M = function(t) {
    var b = 1, E = arguments, i = E.length;
    return t.replace(y, function(c) {
      if (b >= i)
        return c;
      var o = E[b];
      switch (b += 1, c) {
        case "%%":
          return "%";
        case "%s":
          return String(o);
        case "%d":
          return Number(o);
        case "%v":
          return "";
      }
    });
  }, l = function(t, b, E) {
    var i = b.format instanceof Function ? b.format(b.push ? E : E[b.name]) : b.format, c = [t + "=" + i];
    if (b.names)
      for (var o = 0; o < b.names.length; o += 1) {
        var h = b.names[o];
        b.name ? c.push(E[b.name][h]) : c.push(E[b.names[o]]);
      }
    else
      c.push(E[b.name]);
    return M.apply(null, c);
  }, X = [
    "v",
    "o",
    "s",
    "i",
    "u",
    "e",
    "p",
    "c",
    "b",
    "t",
    "r",
    "z",
    "a"
  ], F = ["i", "c", "b", "a"];
  return _n = function(t, b) {
    b = b || {}, t.version == null && (t.version = 0), t.name == null && (t.name = " "), t.media.forEach(function(o) {
      o.payloads == null && (o.payloads = "");
    });
    var E = b.outerOrder || X, i = b.innerOrder || F, c = [];
    return E.forEach(function(o) {
      U[o].forEach(function(h) {
        h.name in t && t[h.name] != null ? c.push(l(o, h, t)) : h.push in t && t[h.push] != null && t[h.push].forEach(function(p) {
          c.push(l(o, h, p));
        });
      });
    }), t.media.forEach(function(o) {
      c.push(l("m", U.m[0], o)), i.forEach(function(h) {
        U[h].forEach(function(p) {
          p.name in o && o[p.name] != null ? c.push(l(h, p, o)) : p.push in o && o[p.push] != null && o[p.push].forEach(function(W) {
            c.push(l(h, p, W));
          });
        });
      });
    }), c.join(`\r
`) + `\r
`;
  }, _n;
}
var Ws;
function gi() {
  if (Ws) return De;
  Ws = 1;
  var U = yl(), y = Tl(), M = Wn();
  return De.grammar = M, De.write = y, De.parse = U.parse, De.parseParams = U.parseParams, De.parseFmtpConfig = U.parseFmtpConfig, De.parsePayloads = U.parsePayloads, De.parseRemoteCandidates = U.parseRemoteCandidates, De.parseImageAttributes = U.parseImageAttributes, De.parseSimulcastStreamList = U.parseSimulcastStreamList, De;
}
var pn, Ks;
function He() {
  if (Ks) return pn;
  Ks = 1;
  function U(K) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(D) {
      return typeof D;
    } : U = function(D) {
      return D && typeof Symbol == "function" && D.constructor === Symbol && D !== Symbol.prototype ? "symbol" : typeof D;
    }, U(K);
  }
  function y(K, Y) {
    if (typeof Y != "function" && Y !== null)
      throw new TypeError("Super expression must either be null or a function");
    K.prototype = Object.create(Y && Y.prototype, { constructor: { value: K, writable: !0, configurable: !0 } }), Y && M(K, Y);
  }
  function M(K, Y) {
    return M = Object.setPrototypeOf || function(B, d) {
      return B.__proto__ = d, B;
    }, M(K, Y);
  }
  function l(K) {
    var Y = t();
    return function() {
      var B = b(K), d;
      if (Y) {
        var _ = b(this).constructor;
        d = Reflect.construct(B, arguments, _);
      } else
        d = B.apply(this, arguments);
      return X(this, d);
    };
  }
  function X(K, Y) {
    return Y && (U(Y) === "object" || typeof Y == "function") ? Y : F(K);
  }
  function F(K) {
    if (K === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return K;
  }
  function t() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function b(K) {
    return b = Object.setPrototypeOf ? Object.getPrototypeOf : function(D) {
      return D.__proto__ || Object.getPrototypeOf(D);
    }, b(K);
  }
  function E(K, Y) {
    var D;
    if (typeof Symbol > "u" || K[Symbol.iterator] == null) {
      if (Array.isArray(K) || (D = i(K)) || Y) {
        D && (K = D);
        var B = 0, d = function() {
        };
        return { s: d, n: function() {
          return B >= K.length ? { done: !0 } : { done: !1, value: K[B++] };
        }, e: function(V) {
          throw V;
        }, f: d };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var _ = !0, R = !1, A;
    return { s: function() {
      D = K[Symbol.iterator]();
    }, n: function() {
      var V = D.next();
      return _ = V.done, V;
    }, e: function(V) {
      R = !0, A = V;
    }, f: function() {
      try {
        !_ && D.return != null && D.return();
      } finally {
        if (R) throw A;
      }
    } };
  }
  function i(K, Y) {
    if (K) {
      if (typeof K == "string") return c(K, Y);
      var D = Object.prototype.toString.call(K).slice(8, -1);
      if (D === "Object" && K.constructor && (D = K.constructor.name), D === "Map" || D === "Set") return Array.from(K);
      if (D === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D)) return c(K, Y);
    }
  }
  function c(K, Y) {
    (Y == null || Y > K.length) && (Y = K.length);
    for (var D = 0, B = new Array(Y); D < Y; D++)
      B[D] = K[D];
    return B;
  }
  function o(K, Y) {
    if (!(K instanceof Y))
      throw new TypeError("Cannot call a class as a function");
  }
  function h(K, Y) {
    for (var D = 0; D < Y.length; D++) {
      var B = Y[D];
      B.enumerable = B.enumerable || !1, B.configurable = !0, "value" in B && (B.writable = !0), Object.defineProperty(K, B.key, B);
    }
  }
  function p(K, Y, D) {
    return Y && h(K.prototype, Y), K;
  }
  var W = gi(), j = Ie(), P = Re(), g = Oe(), k = Bn(), N = Ue(), T = new j("SIPMessage"), v = /* @__PURE__ */ function() {
    function K(Y, D, B, d, _, R) {
      if (o(this, K), !Y || !D || !B)
        return null;
      d = d || {}, this.ua = B, this.headers = {}, this.method = Y, this.ruri = D, this.body = R, this.extraHeaders = g.cloneArray(_), this.ua.configuration.extra_headers && (this.extraHeaders = this.extraHeaders.concat(this.ua.configuration.extra_headers)), d.route_set ? this.setHeader("route", d.route_set) : B.configuration.use_preloaded_route && this.setHeader("route", "<".concat(B.transport.sip_uri, ";lr>")), this.setHeader("via", ""), this.setHeader("max-forwards", P.MAX_FORWARDS);
      var A = d.to_uri || D, G = d.to_tag ? {
        tag: d.to_tag
      } : null, V = typeof d.to_display_name < "u" ? d.to_display_name : null;
      this.to = new k(A, V, G), this.setHeader("to", this.to.toString());
      var x = d.from_uri || B.configuration.uri, u = {
        tag: d.from_tag || g.newTag()
      }, m;
      typeof d.from_display_name < "u" ? m = d.from_display_name : B.configuration.display_name ? m = B.configuration.display_name : m = null, this.from = new k(x, m, u), this.setHeader("from", this.from.toString());
      var L = d.call_id || B.configuration.jssip_id + g.createRandomToken(15);
      this.call_id = L, this.setHeader("call-id", L);
      var q = d.cseq || Math.floor(Math.random() * 1e4);
      this.cseq = q, this.setHeader("cseq", "".concat(q, " ").concat(Y));
    }
    return p(K, [{
      key: "setHeader",
      value: function(D, B) {
        for (var d = new RegExp("^\\s*".concat(D, "\\s*:"), "i"), _ = 0; _ < this.extraHeaders.length; _++)
          d.test(this.extraHeaders[_]) && this.extraHeaders.splice(_, 1);
        this.headers[g.headerize(D)] = Array.isArray(B) ? B : [B];
      }
      /**
       * Get the value of the given header name at the given position.
       * -param {String} name header name
       * -returns {String|undefined} Returns the specified header, null if header doesn't exist.
       */
    }, {
      key: "getHeader",
      value: function(D) {
        var B = this.headers[g.headerize(D)];
        if (B) {
          if (B[0])
            return B[0];
        } else {
          var d = new RegExp("^\\s*".concat(D, "\\s*:"), "i"), _ = E(this.extraHeaders), R;
          try {
            for (_.s(); !(R = _.n()).done; ) {
              var A = R.value;
              if (d.test(A))
                return A.substring(A.indexOf(":") + 1).trim();
            }
          } catch (G) {
            _.e(G);
          } finally {
            _.f();
          }
        }
      }
      /**
       * Get the header/s of the given name.
       * -param {String} name header name
       * -returns {Array} Array with all the headers of the specified name.
       */
    }, {
      key: "getHeaders",
      value: function(D) {
        var B = this.headers[g.headerize(D)], d = [];
        if (B) {
          var _ = E(B), R;
          try {
            for (_.s(); !(R = _.n()).done; ) {
              var A = R.value;
              d.push(A);
            }
          } catch (m) {
            _.e(m);
          } finally {
            _.f();
          }
          return d;
        } else {
          var G = new RegExp("^\\s*".concat(D, "\\s*:"), "i"), V = E(this.extraHeaders), x;
          try {
            for (V.s(); !(x = V.n()).done; ) {
              var u = x.value;
              G.test(u) && d.push(u.substring(u.indexOf(":") + 1).trim());
            }
          } catch (m) {
            V.e(m);
          } finally {
            V.f();
          }
          return d;
        }
      }
      /**
       * Verify the existence of the given header.
       * -param {String} name header name
       * -returns {boolean} true if header with given name exists, false otherwise
       */
    }, {
      key: "hasHeader",
      value: function(D) {
        if (this.headers[g.headerize(D)])
          return !0;
        var B = new RegExp("^\\s*".concat(D, "\\s*:"), "i"), d = E(this.extraHeaders), _;
        try {
          for (d.s(); !(_ = d.n()).done; ) {
            var R = _.value;
            if (B.test(R))
              return !0;
          }
        } catch (A) {
          d.e(A);
        } finally {
          d.f();
        }
        return !1;
      }
      /**
       * Parse the current body as a SDP and store the resulting object
       * into this.sdp.
       * -param {Boolean} force: Parse even if this.sdp already exists.
       *
       * Returns this.sdp.
       */
    }, {
      key: "parseSDP",
      value: function(D) {
        return !D && this.sdp ? this.sdp : (this.sdp = W.parse(this.body || ""), this.sdp);
      }
    }, {
      key: "toString",
      value: function() {
        var D = "".concat(this.method, " ").concat(this.ruri, ` SIP/2.0\r
`);
        for (var B in this.headers)
          if (Object.prototype.hasOwnProperty.call(this.headers, B)) {
            var d = E(this.headers[B]), _;
            try {
              for (d.s(); !(_ = d.n()).done; ) {
                var R = _.value;
                D += "".concat(B, ": ").concat(R, `\r
`);
              }
            } catch (L) {
              d.e(L);
            } finally {
              d.f();
            }
          }
        var A = E(this.extraHeaders), G;
        try {
          for (A.s(); !(G = A.n()).done; ) {
            var V = G.value;
            D += "".concat(V.trim(), `\r
`);
          }
        } catch (L) {
          A.e(L);
        } finally {
          A.f();
        }
        var x = [];
        switch (this.method) {
          case P.REGISTER:
            x.push("path", "gruu");
            break;
          case P.INVITE:
            this.ua.configuration.session_timers && x.push("timer"), (this.ua.contact.pub_gruu || this.ua.contact.temp_gruu) && x.push("gruu"), x.push("ice", "replaces");
            break;
          case P.UPDATE:
            this.ua.configuration.session_timers && x.push("timer"), x.push("ice");
            break;
        }
        x.push("outbound");
        var u = this.ua.configuration.user_agent || P.USER_AGENT;
        if (D += "Allow: ".concat(P.ALLOWED_METHODS, `\r
`), D += "Supported: ".concat(x, `\r
`), D += "User-Agent: ".concat(u, `\r
`), this.body) {
          var m = g.str_utf8_length(this.body);
          D += "Content-Length: ".concat(m, `\r
\r
`), D += this.body;
        } else
          D += `Content-Length: 0\r
\r
`;
        return D;
      }
    }, {
      key: "clone",
      value: function() {
        var D = new K(this.method, this.ruri, this.ua);
        return Object.keys(this.headers).forEach(function(B) {
          D.headers[B] = this.headers[B].slice();
        }, this), D.body = this.body, D.extraHeaders = g.cloneArray(this.extraHeaders), D.to = this.to, D.from = this.from, D.call_id = this.call_id, D.cseq = this.cseq, D;
      }
    }]), K;
  }(), w = /* @__PURE__ */ function(K) {
    y(D, K);
    var Y = l(D);
    function D(B, d, _, R, A) {
      var G;
      return o(this, D), G = Y.call(this, P.INVITE, B, d, _, R, A), G.transaction = null, G;
    }
    return p(D, [{
      key: "cancel",
      value: function(d) {
        this.transaction.cancel(d);
      }
    }, {
      key: "clone",
      value: function() {
        var d = new D(this.ruri, this.ua);
        return Object.keys(this.headers).forEach(function(_) {
          d.headers[_] = this.headers[_].slice();
        }, this), d.body = this.body, d.extraHeaders = g.cloneArray(this.extraHeaders), d.to = this.to, d.from = this.from, d.call_id = this.call_id, d.cseq = this.cseq, d.transaction = this.transaction, d;
      }
    }]), D;
  }(v), I = /* @__PURE__ */ function() {
    function K() {
      o(this, K), this.data = null, this.headers = null, this.method = null, this.via = null, this.via_branch = null, this.call_id = null, this.cseq = null, this.from = null, this.from_tag = null, this.to = null, this.to_tag = null, this.body = null, this.sdp = null;
    }
    return p(K, [{
      key: "addHeader",
      value: function(D, B) {
        var d = {
          raw: B
        };
        D = g.headerize(D), this.headers[D] ? this.headers[D].push(d) : this.headers[D] = [d];
      }
      /**
       * Get the value of the given header name at the given position.
       */
    }, {
      key: "getHeader",
      value: function(D) {
        var B = this.headers[g.headerize(D)];
        if (B) {
          if (B[0])
            return B[0].raw;
        } else
          return;
      }
      /**
       * Get the header/s of the given name.
       */
    }, {
      key: "getHeaders",
      value: function(D) {
        var B = this.headers[g.headerize(D)], d = [];
        if (!B)
          return [];
        var _ = E(B), R;
        try {
          for (_.s(); !(R = _.n()).done; ) {
            var A = R.value;
            d.push(A.raw);
          }
        } catch (G) {
          _.e(G);
        } finally {
          _.f();
        }
        return d;
      }
      /**
       * Verify the existence of the given header.
       */
    }, {
      key: "hasHeader",
      value: function(D) {
        return !!this.headers[g.headerize(D)];
      }
      /**
      * Parse the given header on the given index.
      * -param {String} name header name
      * -param {Number} [idx=0] header index
      * -returns {Object|undefined} Parsed header object, undefined if the header
      *  is not present or in case of a parsing error.
      */
    }, {
      key: "parseHeader",
      value: function(D) {
        var B = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
        if (D = g.headerize(D), this.headers[D]) {
          if (B >= this.headers[D].length) {
            T.debug('not so many "'.concat(D, '" headers present'));
            return;
          }
        } else {
          T.debug('header "'.concat(D, '" not present'));
          return;
        }
        var d = this.headers[D][B], _ = d.raw;
        if (d.parsed)
          return d.parsed;
        var R = N.parse(_, D.replace(/-/g, "_"));
        if (R === -1) {
          this.headers[D].splice(B, 1), T.debug('error parsing "'.concat(D, '" header field with value "').concat(_, '"'));
          return;
        } else
          return d.parsed = R, R;
      }
      /**
       * Message Header attribute selector. Alias of parseHeader.
       * -param {String} name header name
       * -param {Number} [idx=0] header index
       * -returns {Object|undefined} Parsed header object, undefined if the header
       *  is not present or in case of a parsing error.
       *
       * -example
       * message.s('via',3).port
       */
    }, {
      key: "s",
      value: function(D, B) {
        return this.parseHeader(D, B);
      }
      /**
      * Replace the value of the given header by the value.
      * -param {String} name header name
      * -param {String} value header value
      */
    }, {
      key: "setHeader",
      value: function(D, B) {
        var d = {
          raw: B
        };
        this.headers[g.headerize(D)] = [d];
      }
      /**
       * Parse the current body as a SDP and store the resulting object
       * into this.sdp.
       * -param {Boolean} force: Parse even if this.sdp already exists.
       *
       * Returns this.sdp.
       */
    }, {
      key: "parseSDP",
      value: function(D) {
        return !D && this.sdp ? this.sdp : (this.sdp = W.parse(this.body || ""), this.sdp);
      }
    }, {
      key: "toString",
      value: function() {
        return this.data;
      }
    }]), K;
  }(), C = /* @__PURE__ */ function(K) {
    y(D, K);
    var Y = l(D);
    function D(B) {
      var d;
      return o(this, D), d = Y.call(this), d.ua = B, d.headers = {}, d.ruri = null, d.transport = null, d.server_transaction = null, d;
    }
    return p(D, [{
      key: "reply",
      value: function(d, _, R, A, G, V) {
        var x = [], u = this.getHeader("To");
        if (d = d || null, _ = _ || null, !d || d < 100 || d > 699)
          throw new TypeError("Invalid status_code: ".concat(d));
        if (_ && typeof _ != "string" && !(_ instanceof String))
          throw new TypeError("Invalid reason_phrase: ".concat(_));
        _ = _ || P.REASON_PHRASE[d] || "", R = g.cloneArray(R), this.ua.configuration.extra_headers && (R = R.concat(this.ua.configuration.extra_headers));
        var m = "SIP/2.0 ".concat(d, " ").concat(_, `\r
`);
        if (this.method === P.INVITE && d > 100 && d <= 200) {
          var L = this.getHeaders("record-route"), q = E(L), $;
          try {
            for (q.s(); !($ = q.n()).done; ) {
              var z = $.value;
              m += "Record-Route: ".concat(z, `\r
`);
            }
          } catch (ue) {
            q.e(ue);
          } finally {
            q.f();
          }
        }
        var ee = this.getHeaders("via"), Z = E(ee), re;
        try {
          for (Z.s(); !(re = Z.n()).done; ) {
            var se = re.value;
            m += "Via: ".concat(se, `\r
`);
          }
        } catch (ue) {
          Z.e(ue);
        } finally {
          Z.f();
        }
        !this.to_tag && d > 100 ? u += ";tag=".concat(g.newTag()) : this.to_tag && !this.s("to").hasParam("tag") && (u += ";tag=".concat(this.to_tag)), m += "To: ".concat(u, `\r
`), m += "From: ".concat(this.getHeader("From"), `\r
`), m += "Call-ID: ".concat(this.call_id, `\r
`), m += "CSeq: ".concat(this.cseq, " ").concat(this.method, `\r
`);
        var ne = E(R), he;
        try {
          for (ne.s(); !(he = ne.n()).done; ) {
            var pe = he.value;
            m += "".concat(pe.trim(), `\r
`);
          }
        } catch (ue) {
          ne.e(ue);
        } finally {
          ne.f();
        }
        switch (this.method) {
          case P.INVITE:
            this.ua.configuration.session_timers && x.push("timer"), (this.ua.contact.pub_gruu || this.ua.contact.temp_gruu) && x.push("gruu"), x.push("ice", "replaces");
            break;
          case P.UPDATE:
            this.ua.configuration.session_timers && x.push("timer"), A && x.push("ice"), x.push("replaces");
        }
        if (x.push("outbound"), this.method === P.OPTIONS ? (m += "Allow: ".concat(P.ALLOWED_METHODS, `\r
`), m += "Accept: ".concat(P.ACCEPTED_BODY_TYPES, `\r
`)) : d === 405 ? m += "Allow: ".concat(P.ALLOWED_METHODS, `\r
`) : d === 415 && (m += "Accept: ".concat(P.ACCEPTED_BODY_TYPES, `\r
`)), m += "Supported: ".concat(x, `\r
`), A) {
          var Te = g.str_utf8_length(A);
          m += `Content-Type: application/sdp\r
`, m += "Content-Length: ".concat(Te, `\r
\r
`), m += A;
        } else
          m += "Content-Length: ".concat(0, `\r
\r
`);
        this.server_transaction.receiveResponse(d, m, G, V);
      }
      /**
      * Stateless reply.
      * -param {Number} code status code
      * -param {String} reason reason phrase
      */
    }, {
      key: "reply_sl",
      value: function() {
        var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, _ = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null, R = this.getHeaders("via");
        if (!d || d < 100 || d > 699)
          throw new TypeError("Invalid status_code: ".concat(d));
        if (_ && typeof _ != "string" && !(_ instanceof String))
          throw new TypeError("Invalid reason_phrase: ".concat(_));
        _ = _ || P.REASON_PHRASE[d] || "";
        var A = "SIP/2.0 ".concat(d, " ").concat(_, `\r
`), G = E(R), V;
        try {
          for (G.s(); !(V = G.n()).done; ) {
            var x = V.value;
            A += "Via: ".concat(x, `\r
`);
          }
        } catch ($) {
          G.e($);
        } finally {
          G.f();
        }
        var u = this.getHeader("To");
        if (!this.to_tag && d > 100 ? u += ";tag=".concat(g.newTag()) : this.to_tag && !this.s("to").hasParam("tag") && (u += ";tag=".concat(this.to_tag)), A += "To: ".concat(u, `\r
`), A += "From: ".concat(this.getHeader("From"), `\r
`), A += "Call-ID: ".concat(this.call_id, `\r
`), A += "CSeq: ".concat(this.cseq, " ").concat(this.method, `\r
`), this.ua.configuration.extra_headers) {
          var m = E(this.ua.configuration.extra_headers), L;
          try {
            for (m.s(); !(L = m.n()).done; ) {
              var q = L.value;
              A += "".concat(q.trim(), `\r
`);
            }
          } catch ($) {
            m.e($);
          } finally {
            m.f();
          }
        }
        A += "Content-Length: ".concat(0, `\r
\r
`), this.transport.send(A);
      }
    }]), D;
  }(I), O = /* @__PURE__ */ function(K) {
    y(D, K);
    var Y = l(D);
    function D() {
      var B;
      return o(this, D), B = Y.call(this), B.headers = {}, B.status_code = null, B.reason_phrase = null, B;
    }
    return D;
  }(I);
  return pn = {
    OutgoingRequest: v,
    InitialOutgoingInviteRequest: w,
    IncomingRequest: C,
    IncomingResponse: O
  }, pn;
}
var vn, zs;
function Sl() {
  if (zs) return vn;
  zs = 1;
  function U(t, b) {
    if (!(t instanceof b))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(t, b) {
    for (var E = 0; E < b.length; E++) {
      var i = b[E];
      i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i);
    }
  }
  function M(t, b, E) {
    return b && y(t.prototype, b), t;
  }
  var l = Ie(), X = Oe(), F = new l("DigestAuthentication");
  return vn = /* @__PURE__ */ function() {
    function t(b) {
      U(this, t), this._credentials = b, this._cnonce = null, this._nc = 0, this._ncHex = "00000000", this._algorithm = null, this._realm = null, this._nonce = null, this._opaque = null, this._stale = null, this._qop = null, this._method = null, this._uri = null, this._ha1 = null, this._response = null;
    }
    return M(t, [{
      key: "get",
      value: function(E) {
        switch (E) {
          case "realm":
            return this._realm;
          case "ha1":
            return this._ha1;
          default:
            F.warn('get() | cannot get "%s" parameter', E);
            return;
        }
      }
      /**
      * Performs Digest authentication given a SIP request and the challenge
      * received in a response to that request.
      * Returns true if auth was successfully generated, false otherwise.
      */
    }, {
      key: "authenticate",
      value: function(E, i) {
        var c = E.method, o = E.ruri, h = E.body, p = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
        if (this._algorithm = i.algorithm, this._realm = i.realm, this._nonce = i.nonce, this._opaque = i.opaque, this._stale = i.stale, this._algorithm) {
          if (this._algorithm !== "MD5")
            return F.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'), !1;
        } else
          this._algorithm = "MD5";
        if (!this._nonce)
          return F.warn("authenticate() | challenge without Digest nonce, authentication aborted"), !1;
        if (!this._realm)
          return F.warn("authenticate() | challenge without Digest realm, authentication aborted"), !1;
        if (!this._credentials.password) {
          if (!this._credentials.ha1)
            return F.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"), !1;
          if (this._credentials.realm !== this._realm)
            return F.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]', this._credentials.realm, this._realm), !1;
        }
        if (i.qop)
          if (i.qop.indexOf("auth-int") > -1)
            this._qop = "auth-int";
          else if (i.qop.indexOf("auth") > -1)
            this._qop = "auth";
          else
            return F.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'), !1;
        else
          this._qop = null;
        this._method = c, this._uri = o, this._cnonce = p || X.createRandomToken(12), this._nc += 1;
        var W = Number(this._nc).toString(16);
        this._ncHex = "00000000".substr(0, 8 - W.length) + W, this._nc === 4294967296 && (this._nc = 1, this._ncHex = "00000001"), this._credentials.password ? this._ha1 = X.calculateMD5("".concat(this._credentials.username, ":").concat(this._realm, ":").concat(this._credentials.password)) : this._ha1 = this._credentials.ha1;
        var j, P;
        return this._qop === "auth" ? (j = "".concat(this._method, ":").concat(this._uri), P = X.calculateMD5(j), F.debug('authenticate() | using qop=auth [a2:"%s"]', j), this._response = X.calculateMD5("".concat(this._ha1, ":").concat(this._nonce, ":").concat(this._ncHex, ":").concat(this._cnonce, ":auth:").concat(P))) : this._qop === "auth-int" ? (j = "".concat(this._method, ":").concat(this._uri, ":").concat(X.calculateMD5(h || "")), P = X.calculateMD5(j), F.debug('authenticate() | using qop=auth-int [a2:"%s"]', j), this._response = X.calculateMD5("".concat(this._ha1, ":").concat(this._nonce, ":").concat(this._ncHex, ":").concat(this._cnonce, ":auth-int:").concat(P))) : this._qop === null && (j = "".concat(this._method, ":").concat(this._uri), P = X.calculateMD5(j), F.debug('authenticate() | using qop=null [a2:"%s"]', j), this._response = X.calculateMD5("".concat(this._ha1, ":").concat(this._nonce, ":").concat(P))), F.debug("authenticate() | response generated"), !0;
      }
      /**
      * Return the Proxy-Authorization or WWW-Authorization header value.
      */
    }, {
      key: "toString",
      value: function() {
        var E = [];
        if (!this._response)
          throw new Error("response field does not exist, cannot generate Authorization header");
        return E.push("algorithm=".concat(this._algorithm)), E.push('username="'.concat(this._credentials.username, '"')), E.push('realm="'.concat(this._realm, '"')), E.push('nonce="'.concat(this._nonce, '"')), E.push('uri="'.concat(this._uri, '"')), E.push('response="'.concat(this._response, '"')), this._opaque && E.push('opaque="'.concat(this._opaque, '"')), this._qop && (E.push("qop=".concat(this._qop)), E.push('cnonce="'.concat(this._cnonce, '"')), E.push("nc=".concat(this._ncHex))), "Digest ".concat(E.join(", "));
      }
    }]), t;
  }(), vn;
}
var mn, Ys;
function yi() {
  if (Ys) return mn;
  Ys = 1;
  var U = 500, y = 4e3, M = 5e3;
  return mn = {
    T1: U,
    T2: y,
    T4: M,
    TIMER_B: 64 * U,
    TIMER_D: 0 * U,
    TIMER_F: 64 * U,
    TIMER_H: 64 * U,
    TIMER_I: 0 * U,
    TIMER_J: 0 * U,
    TIMER_K: 0 * M,
    TIMER_L: 64 * U,
    TIMER_M: 64 * U,
    PROVISIONAL_RESPONSE_INTERVAL: 6e4
    // See RFC 3261 Section 13.3.1.1
  }, mn;
}
var gn, $s;
function ct() {
  if ($s) return gn;
  $s = 1;
  function U(D) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(d) {
      return typeof d;
    } : U = function(d) {
      return d && typeof Symbol == "function" && d.constructor === Symbol && d !== Symbol.prototype ? "symbol" : typeof d;
    }, U(D);
  }
  function y(D, B) {
    if (!(D instanceof B))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(D, B) {
    for (var d = 0; d < B.length; d++) {
      var _ = B[d];
      _.enumerable = _.enumerable || !1, _.configurable = !0, "value" in _ && (_.writable = !0), Object.defineProperty(D, _.key, _);
    }
  }
  function l(D, B, d) {
    return B && M(D.prototype, B), D;
  }
  function X(D, B) {
    if (typeof B != "function" && B !== null)
      throw new TypeError("Super expression must either be null or a function");
    D.prototype = Object.create(B && B.prototype, { constructor: { value: D, writable: !0, configurable: !0 } }), B && F(D, B);
  }
  function F(D, B) {
    return F = Object.setPrototypeOf || function(_, R) {
      return _.__proto__ = R, _;
    }, F(D, B);
  }
  function t(D) {
    var B = i();
    return function() {
      var _ = c(D), R;
      if (B) {
        var A = c(this).constructor;
        R = Reflect.construct(_, arguments, A);
      } else
        R = _.apply(this, arguments);
      return b(this, R);
    };
  }
  function b(D, B) {
    return B && (U(B) === "object" || typeof B == "function") ? B : E(D);
  }
  function E(D) {
    if (D === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return D;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(D) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(d) {
      return d.__proto__ || Object.getPrototypeOf(d);
    }, c(D);
  }
  var o = Be().EventEmitter, h = Ie(), p = Re(), W = He(), j = yi(), P = new h("NonInviteClientTransaction"), g = new h("InviteClientTransaction"), k = new h("AckClientTransaction"), N = new h("NonInviteServerTransaction"), T = new h("InviteServerTransaction"), v = {
    // Transaction states.
    STATUS_TRYING: 1,
    STATUS_PROCEEDING: 2,
    STATUS_CALLING: 3,
    STATUS_ACCEPTED: 4,
    STATUS_COMPLETED: 5,
    STATUS_TERMINATED: 6,
    STATUS_CONFIRMED: 7,
    // Transaction types.
    NON_INVITE_CLIENT: "nict",
    NON_INVITE_SERVER: "nist",
    INVITE_CLIENT: "ict",
    INVITE_SERVER: "ist"
  }, w = /* @__PURE__ */ function(D) {
    X(d, D);
    var B = t(d);
    function d(_, R, A, G) {
      var V;
      y(this, d), V = B.call(this), V.type = v.NON_INVITE_CLIENT, V.id = "z9hG4bK".concat(Math.floor(Math.random() * 1e7)), V.ua = _, V.transport = R, V.request = A, V.eventHandlers = G;
      var x = "SIP/2.0/".concat(R.via_transport);
      return x += " ".concat(_.configuration.via_host, ";branch=").concat(V.id), V.request.setHeader("via", x), V.ua.newTransaction(E(V)), V;
    }
    return l(d, [{
      key: "stateChanged",
      value: function(R) {
        this.state = R, this.emit("stateChanged");
      }
    }, {
      key: "send",
      value: function() {
        var R = this;
        this.stateChanged(v.STATUS_TRYING), this.F = setTimeout(function() {
          R.timer_F();
        }, j.TIMER_F), this.transport.send(this.request) || this.onTransportError();
      }
    }, {
      key: "onTransportError",
      value: function() {
        P.debug("transport error occurred, deleting transaction ".concat(this.id)), clearTimeout(this.F), clearTimeout(this.K), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this), this.eventHandlers.onTransportError();
      }
    }, {
      key: "timer_F",
      value: function() {
        P.debug("Timer F expired for transaction ".concat(this.id)), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this), this.eventHandlers.onRequestTimeout();
      }
    }, {
      key: "timer_K",
      value: function() {
        this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this);
      }
    }, {
      key: "receiveResponse",
      value: function(R) {
        var A = this, G = R.status_code;
        if (G < 200)
          switch (this.state) {
            case v.STATUS_TRYING:
            case v.STATUS_PROCEEDING:
              this.stateChanged(v.STATUS_PROCEEDING), this.eventHandlers.onReceiveResponse(R);
              break;
          }
        else
          switch (this.state) {
            case v.STATUS_TRYING:
            case v.STATUS_PROCEEDING:
              this.stateChanged(v.STATUS_COMPLETED), clearTimeout(this.F), G === 408 ? this.eventHandlers.onRequestTimeout() : this.eventHandlers.onReceiveResponse(R), this.K = setTimeout(function() {
                A.timer_K();
              }, j.TIMER_K);
              break;
            case v.STATUS_COMPLETED:
              break;
          }
      }
    }, {
      key: "C",
      get: function() {
        return v;
      }
    }]), d;
  }(o), I = /* @__PURE__ */ function(D) {
    X(d, D);
    var B = t(d);
    function d(_, R, A, G) {
      var V;
      y(this, d), V = B.call(this), V.type = v.INVITE_CLIENT, V.id = "z9hG4bK".concat(Math.floor(Math.random() * 1e7)), V.ua = _, V.transport = R, V.request = A, V.eventHandlers = G, A.transaction = E(V);
      var x = "SIP/2.0/".concat(R.via_transport);
      return x += " ".concat(_.configuration.via_host, ";branch=").concat(V.id), V.request.setHeader("via", x), V.ua.newTransaction(E(V)), V;
    }
    return l(d, [{
      key: "stateChanged",
      value: function(R) {
        this.state = R, this.emit("stateChanged");
      }
    }, {
      key: "send",
      value: function() {
        var R = this;
        this.stateChanged(v.STATUS_CALLING), this.B = setTimeout(function() {
          R.timer_B();
        }, j.TIMER_B), this.transport.send(this.request) || this.onTransportError();
      }
    }, {
      key: "onTransportError",
      value: function() {
        clearTimeout(this.B), clearTimeout(this.D), clearTimeout(this.M), this.state !== v.STATUS_ACCEPTED && (g.debug("transport error occurred, deleting transaction ".concat(this.id)), this.eventHandlers.onTransportError()), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this);
      }
      // RFC 6026 7.2.
    }, {
      key: "timer_M",
      value: function() {
        g.debug("Timer M expired for transaction ".concat(this.id)), this.state === v.STATUS_ACCEPTED && (clearTimeout(this.B), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this));
      }
      // RFC 3261 17.1.1.
    }, {
      key: "timer_B",
      value: function() {
        g.debug("Timer B expired for transaction ".concat(this.id)), this.state === v.STATUS_CALLING && (this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this), this.eventHandlers.onRequestTimeout());
      }
    }, {
      key: "timer_D",
      value: function() {
        g.debug("Timer D expired for transaction ".concat(this.id)), clearTimeout(this.B), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this);
      }
    }, {
      key: "sendACK",
      value: function(R) {
        var A = this, G = new W.OutgoingRequest(p.ACK, this.request.ruri, this.ua, {
          route_set: this.request.getHeaders("route"),
          call_id: this.request.getHeader("call-id"),
          cseq: this.request.cseq
        });
        G.setHeader("from", this.request.getHeader("from")), G.setHeader("via", this.request.getHeader("via")), G.setHeader("to", R.getHeader("to")), this.D = setTimeout(function() {
          A.timer_D();
        }, j.TIMER_D), this.transport.send(G);
      }
    }, {
      key: "cancel",
      value: function(R) {
        if (this.state === v.STATUS_PROCEEDING) {
          var A = new W.OutgoingRequest(p.CANCEL, this.request.ruri, this.ua, {
            route_set: this.request.getHeaders("route"),
            call_id: this.request.getHeader("call-id"),
            cseq: this.request.cseq
          });
          A.setHeader("from", this.request.getHeader("from")), A.setHeader("via", this.request.getHeader("via")), A.setHeader("to", this.request.getHeader("to")), R && A.setHeader("reason", R), this.transport.send(A);
        }
      }
    }, {
      key: "receiveResponse",
      value: function(R) {
        var A = this, G = R.status_code;
        if (G >= 100 && G <= 199)
          switch (this.state) {
            case v.STATUS_CALLING:
              this.stateChanged(v.STATUS_PROCEEDING), this.eventHandlers.onReceiveResponse(R);
              break;
            case v.STATUS_PROCEEDING:
              this.eventHandlers.onReceiveResponse(R);
              break;
          }
        else if (G >= 200 && G <= 299)
          switch (this.state) {
            case v.STATUS_CALLING:
            case v.STATUS_PROCEEDING:
              this.stateChanged(v.STATUS_ACCEPTED), this.M = setTimeout(function() {
                A.timer_M();
              }, j.TIMER_M), this.eventHandlers.onReceiveResponse(R);
              break;
            case v.STATUS_ACCEPTED:
              this.eventHandlers.onReceiveResponse(R);
              break;
          }
        else if (G >= 300 && G <= 699)
          switch (this.state) {
            case v.STATUS_CALLING:
            case v.STATUS_PROCEEDING:
              this.stateChanged(v.STATUS_COMPLETED), this.sendACK(R), this.eventHandlers.onReceiveResponse(R);
              break;
            case v.STATUS_COMPLETED:
              this.sendACK(R);
              break;
          }
      }
    }, {
      key: "C",
      get: function() {
        return v;
      }
    }]), d;
  }(o), C = /* @__PURE__ */ function(D) {
    X(d, D);
    var B = t(d);
    function d(_, R, A, G) {
      var V;
      y(this, d), V = B.call(this), V.id = "z9hG4bK".concat(Math.floor(Math.random() * 1e7)), V.transport = R, V.request = A, V.eventHandlers = G;
      var x = "SIP/2.0/".concat(R.via_transport);
      return x += " ".concat(_.configuration.via_host, ";branch=").concat(V.id), V.request.setHeader("via", x), V;
    }
    return l(d, [{
      key: "send",
      value: function() {
        this.transport.send(this.request) || this.onTransportError();
      }
    }, {
      key: "onTransportError",
      value: function() {
        k.debug("transport error occurred for transaction ".concat(this.id)), this.eventHandlers.onTransportError();
      }
    }, {
      key: "C",
      get: function() {
        return v;
      }
    }]), d;
  }(o), O = /* @__PURE__ */ function(D) {
    X(d, D);
    var B = t(d);
    function d(_, R, A) {
      var G;
      return y(this, d), G = B.call(this), G.type = v.NON_INVITE_SERVER, G.id = A.via_branch, G.ua = _, G.transport = R, G.request = A, G.last_response = "", A.server_transaction = E(G), G.state = v.STATUS_TRYING, _.newTransaction(E(G)), G;
    }
    return l(d, [{
      key: "stateChanged",
      value: function(R) {
        this.state = R, this.emit("stateChanged");
      }
    }, {
      key: "timer_J",
      value: function() {
        N.debug("Timer J expired for transaction ".concat(this.id)), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this);
      }
    }, {
      key: "onTransportError",
      value: function() {
        this.transportError || (this.transportError = !0, N.debug("transport error occurred, deleting transaction ".concat(this.id)), clearTimeout(this.J), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this));
      }
    }, {
      key: "receiveResponse",
      value: function(R, A, G, V) {
        var x = this;
        if (R === 100)
          switch (this.state) {
            case v.STATUS_TRYING:
              this.stateChanged(v.STATUS_PROCEEDING), this.transport.send(A) || this.onTransportError();
              break;
            case v.STATUS_PROCEEDING:
              this.last_response = A, this.transport.send(A) ? G && G() : (this.onTransportError(), V && V());
              break;
          }
        else if (R >= 200 && R <= 699)
          switch (this.state) {
            case v.STATUS_TRYING:
            case v.STATUS_PROCEEDING:
              this.stateChanged(v.STATUS_COMPLETED), this.last_response = A, this.J = setTimeout(function() {
                x.timer_J();
              }, j.TIMER_J), this.transport.send(A) ? G && G() : (this.onTransportError(), V && V());
              break;
            case v.STATUS_COMPLETED:
              break;
          }
      }
    }, {
      key: "C",
      get: function() {
        return v;
      }
    }]), d;
  }(o), K = /* @__PURE__ */ function(D) {
    X(d, D);
    var B = t(d);
    function d(_, R, A) {
      var G;
      return y(this, d), G = B.call(this), G.type = v.INVITE_SERVER, G.id = A.via_branch, G.ua = _, G.transport = R, G.request = A, G.last_response = "", A.server_transaction = E(G), G.state = v.STATUS_PROCEEDING, _.newTransaction(E(G)), G.resendProvisionalTimer = null, A.reply(100), G;
    }
    return l(d, [{
      key: "stateChanged",
      value: function(R) {
        this.state = R, this.emit("stateChanged");
      }
    }, {
      key: "timer_H",
      value: function() {
        T.debug("Timer H expired for transaction ".concat(this.id)), this.state === v.STATUS_COMPLETED && T.debug("ACK not received, dialog will be terminated"), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this);
      }
    }, {
      key: "timer_I",
      value: function() {
        this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this);
      }
      // RFC 6026 7.1.
    }, {
      key: "timer_L",
      value: function() {
        T.debug("Timer L expired for transaction ".concat(this.id)), this.state === v.STATUS_ACCEPTED && (this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this));
      }
    }, {
      key: "onTransportError",
      value: function() {
        this.transportError || (this.transportError = !0, T.debug("transport error occurred, deleting transaction ".concat(this.id)), this.resendProvisionalTimer !== null && (clearInterval(this.resendProvisionalTimer), this.resendProvisionalTimer = null), clearTimeout(this.L), clearTimeout(this.H), clearTimeout(this.I), this.stateChanged(v.STATUS_TERMINATED), this.ua.destroyTransaction(this));
      }
    }, {
      key: "resend_provisional",
      value: function() {
        this.transport.send(this.last_response) || this.onTransportError();
      }
      // INVITE Server Transaction RFC 3261 17.2.1.
    }, {
      key: "receiveResponse",
      value: function(R, A, G, V) {
        var x = this;
        if (R >= 100 && R <= 199)
          switch (this.state) {
            case v.STATUS_PROCEEDING:
              this.transport.send(A) || this.onTransportError(), this.last_response = A;
              break;
          }
        if (R > 100 && R <= 199 && this.state === v.STATUS_PROCEEDING)
          this.resendProvisionalTimer === null && (this.resendProvisionalTimer = setInterval(function() {
            x.resend_provisional();
          }, j.PROVISIONAL_RESPONSE_INTERVAL));
        else if (R >= 200 && R <= 299)
          switch (this.state) {
            case v.STATUS_PROCEEDING:
              this.stateChanged(v.STATUS_ACCEPTED), this.last_response = A, this.L = setTimeout(function() {
                x.timer_L();
              }, j.TIMER_L), this.resendProvisionalTimer !== null && (clearInterval(this.resendProvisionalTimer), this.resendProvisionalTimer = null);
            /* falls through */
            case v.STATUS_ACCEPTED:
              this.transport.send(A) ? G && G() : (this.onTransportError(), V && V());
              break;
          }
        else if (R >= 300 && R <= 699)
          switch (this.state) {
            case v.STATUS_PROCEEDING:
              this.resendProvisionalTimer !== null && (clearInterval(this.resendProvisionalTimer), this.resendProvisionalTimer = null), this.transport.send(A) ? (this.stateChanged(v.STATUS_COMPLETED), this.H = setTimeout(function() {
                x.timer_H();
              }, j.TIMER_H), G && G()) : (this.onTransportError(), V && V());
              break;
          }
      }
    }, {
      key: "C",
      get: function() {
        return v;
      }
    }]), d;
  }(o);
  function Y(D, B) {
    var d = D._transactions, _;
    switch (B.method) {
      case p.INVITE:
        if (_ = d.ist[B.via_branch], _) {
          switch (_.state) {
            case v.STATUS_PROCEEDING:
              _.transport.send(_.last_response);
              break;
            // RFC 6026 7.1 Invite retransmission.
            // Received while in C.STATUS_ACCEPTED state. Absorb it.
            case v.STATUS_ACCEPTED:
              break;
          }
          return !0;
        }
        break;
      case p.ACK:
        if (_ = d.ist[B.via_branch], _) {
          if (_.state === v.STATUS_ACCEPTED)
            return !1;
          if (_.state === v.STATUS_COMPLETED)
            return _.state = v.STATUS_CONFIRMED, _.I = setTimeout(function() {
              _.timer_I();
            }, j.TIMER_I), !0;
        } else
          return !1;
        break;
      case p.CANCEL:
        return _ = d.ist[B.via_branch], _ ? (B.reply_sl(200), _.state !== v.STATUS_PROCEEDING) : (B.reply_sl(481), !0);
      default:
        if (_ = d.nist[B.via_branch], _) {
          switch (_.state) {
            case v.STATUS_TRYING:
              break;
            case v.STATUS_PROCEEDING:
            case v.STATUS_COMPLETED:
              _.transport.send(_.last_response);
              break;
          }
          return !0;
        }
        break;
    }
  }
  return gn = {
    C: v,
    NonInviteClientTransaction: w,
    InviteClientTransaction: I,
    AckClientTransaction: C,
    NonInviteServerTransaction: O,
    InviteServerTransaction: K,
    checkTransaction: Y
  }, gn;
}
var yn, Js;
function ht() {
  if (Js) return yn;
  Js = 1;
  function U(i, c) {
    if (!(i instanceof c))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(i, c) {
    for (var o = 0; o < c.length; o++) {
      var h = c[o];
      h.enumerable = h.enumerable || !1, h.configurable = !0, "value" in h && (h.writable = !0), Object.defineProperty(i, h.key, h);
    }
  }
  function M(i, c, o) {
    return c && y(i.prototype, c), i;
  }
  var l = Ie(), X = Re(), F = Sl(), t = ct(), b = new l("RequestSender"), E = {
    onRequestTimeout: function() {
    },
    onTransportError: function() {
    },
    onReceiveResponse: function() {
    },
    onAuthenticated: function() {
    }
  };
  return yn = /* @__PURE__ */ function() {
    function i(c, o, h) {
      U(this, i), this._ua = c, this._eventHandlers = h, this._method = o.method, this._request = o, this._auth = null, this._challenged = !1, this._staled = !1;
      for (var p in E)
        Object.prototype.hasOwnProperty.call(E, p) && (this._eventHandlers[p] || (this._eventHandlers[p] = E[p]));
      c.status === c.C.STATUS_USER_CLOSED && (this._method !== X.BYE || this._method !== X.ACK) && this._eventHandlers.onTransportError();
    }
    return M(i, [{
      key: "send",
      value: function() {
        var o = this, h = {
          onRequestTimeout: function() {
            o._eventHandlers.onRequestTimeout();
          },
          onTransportError: function() {
            o._eventHandlers.onTransportError();
          },
          onReceiveResponse: function(W) {
            o._receiveResponse(W);
          }
        };
        switch (this._method) {
          case "INVITE":
            this.clientTransaction = new t.InviteClientTransaction(this._ua, this._ua.transport, this._request, h);
            break;
          case "ACK":
            this.clientTransaction = new t.AckClientTransaction(this._ua, this._ua.transport, this._request, h);
            break;
          default:
            this.clientTransaction = new t.NonInviteClientTransaction(this._ua, this._ua.transport, this._request, h);
        }
        this._ua._configuration.authorization_jwt && this._request.setHeader("Authorization", this._ua._configuration.authorization_jwt), this.clientTransaction.send();
      }
      /**
      * Called from client transaction when receiving a correct response to the request.
      * Authenticate request if needed or pass the response back to the applicant.
      */
    }, {
      key: "_receiveResponse",
      value: function(o) {
        var h, p, W = o.status_code;
        if ((W === 401 || W === 407) && (this._ua.configuration.password !== null || this._ua.configuration.ha1 !== null)) {
          if (o.status_code === 401 ? (h = o.parseHeader("www-authenticate"), p = "authorization") : (h = o.parseHeader("proxy-authenticate"), p = "proxy-authorization"), !h) {
            b.debug("".concat(o.status_code, " with wrong or missing challenge, cannot authenticate")), this._eventHandlers.onReceiveResponse(o);
            return;
          }
          if (!this._challenged || !this._staled && h.stale === !0) {
            if (this._auth || (this._auth = new F({
              username: this._ua.configuration.authorization_user,
              password: this._ua.configuration.password,
              realm: this._ua.configuration.realm,
              ha1: this._ua.configuration.ha1
            })), !this._auth.authenticate(this._request, h)) {
              this._eventHandlers.onReceiveResponse(o);
              return;
            }
            this._challenged = !0, this._ua.set("realm", this._auth.get("realm")), this._ua.set("ha1", this._auth.get("ha1")), h.stale && (this._staled = !0), this._request = this._request.clone(), this._request.cseq += 1, this._request.setHeader("cseq", "".concat(this._request.cseq, " ").concat(this._method)), this._request.setHeader(p, this._auth.toString()), this._eventHandlers.onAuthenticated(this._request), this.send();
          } else
            this._eventHandlers.onReceiveResponse(o);
        } else
          this._eventHandlers.onReceiveResponse(o);
      }
    }]), i;
  }(), yn;
}
var Tn, Xs;
function Cl() {
  if (Xs) return Tn;
  Xs = 1;
  function U(c, o) {
    if (!(c instanceof o))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(c, o) {
    for (var h = 0; h < o.length; h++) {
      var p = o[h];
      p.enumerable = p.enumerable || !1, p.configurable = !0, "value" in p && (p.writable = !0), Object.defineProperty(c, p.key, p);
    }
  }
  function M(c, o, h) {
    return o && y(c.prototype, o), c;
  }
  var l = Ie(), X = Oe(), F = Re(), t = He(), b = ht(), E = new l("Registrator"), i = 10;
  return Tn = /* @__PURE__ */ function() {
    function c(o, h) {
      U(this, c), this._reg_id = 1, this._ua = o, this._transport = h, this._registrar = o.configuration.registrar_server, this._expires = o.configuration.register_expires, this._call_id = X.createRandomToken(22), this._cseq = 0, this._to_uri = o.configuration.uri, this._registrationTimer = null, this._registering = !1, this._registered = !1, this._contact = this._ua.contact.toString(), this._contact += ";+sip.ice", this._extraHeaders = [], this._extraContactParams = "", this._sipInstance = '"<urn:uuid:'.concat(this._ua.configuration.instance_id, '>"'), this._contact += ";reg-id=".concat(this._reg_id), this._contact += ";+sip.instance=".concat(this._sipInstance);
    }
    return M(c, [{
      key: "setExtraHeaders",
      value: function(h) {
        Array.isArray(h) || (h = []), this._extraHeaders = h.slice();
      }
    }, {
      key: "setExtraContactParams",
      value: function(h) {
        h instanceof Object || (h = {}), this._extraContactParams = "";
        for (var p in h)
          if (Object.prototype.hasOwnProperty.call(h, p)) {
            var W = h[p];
            this._extraContactParams += ";".concat(p), W && (this._extraContactParams += "=".concat(W));
          }
      }
    }, {
      key: "register",
      value: function() {
        var h = this;
        if (this._registering) {
          E.debug("Register request in progress...");
          return;
        }
        var p = this._extraHeaders.slice();
        p.push("Contact: ".concat(this._contact, ";expires=").concat(this._expires).concat(this._extraContactParams)), p.push("Expires: ".concat(this._expires));
        var W = new t.OutgoingRequest(F.REGISTER, this._registrar, this._ua, {
          to_uri: this._to_uri,
          call_id: this._call_id,
          cseq: this._cseq += 1
        }, p), j = new b(this._ua, W, {
          onRequestTimeout: function() {
            h._registrationFailure(null, F.causes.REQUEST_TIMEOUT);
          },
          onTransportError: function() {
            h._registrationFailure(null, F.causes.CONNECTION_ERROR);
          },
          // Increase the CSeq on authentication.
          onAuthenticated: function() {
            h._cseq += 1;
          },
          onReceiveResponse: function(g) {
            if (g.cseq === h._cseq)
              switch (h._registrationTimer !== null && (clearTimeout(h._registrationTimer), h._registrationTimer = null), !0) {
                case /^1[0-9]{2}$/.test(g.status_code):
                  break;
                case /^2[0-9]{2}$/.test(g.status_code): {
                  if (h._registering = !1, !g.hasHeader("Contact")) {
                    E.debug("no Contact header in response to REGISTER, response ignored");
                    break;
                  }
                  var k = g.headers.Contact.reduce(function(I, C) {
                    return I.concat(C.parsed);
                  }, []), N = k.find(function(I) {
                    return h._sipInstance === I.getParam("+sip.instance") && h._reg_id === parseInt(I.getParam("reg-id"));
                  });
                  if (N || (N = k.find(function(I) {
                    return I.uri.user === h._ua.contact.uri.user;
                  })), !N) {
                    E.debug("no Contact header pointing to us, response ignored");
                    break;
                  }
                  var T = N.getParam("expires");
                  !T && g.hasHeader("expires") && (T = g.getHeader("expires")), T || (T = h._expires), T = Number(T), T < i && (T = i);
                  var v = T > 64 ? T * 1e3 / 2 + Math.floor((T / 2 - 32) * 1e3 * Math.random()) : T * 1e3 - 5e3;
                  h._registrationTimer = setTimeout(function() {
                    h._registrationTimer = null, h._ua.listeners("registrationExpiring").length === 0 ? h.register() : h._ua.emit("registrationExpiring");
                  }, v), N.hasParam("temp-gruu") && (h._ua.contact.temp_gruu = N.getParam("temp-gruu").replace(/"/g, "")), N.hasParam("pub-gruu") && (h._ua.contact.pub_gruu = N.getParam("pub-gruu").replace(/"/g, "")), h._registered || (h._registered = !0, h._ua.registered({
                    response: g
                  }));
                  break;
                }
                // Interval too brief RFC3261 10.2.8.
                case /^423$/.test(g.status_code): {
                  g.hasHeader("min-expires") ? (h._expires = Number(g.getHeader("min-expires")), h._expires < i && (h._expires = i), h.register()) : (E.debug("423 response received for REGISTER without Min-Expires"), h._registrationFailure(g, F.causes.SIP_FAILURE_CODE));
                  break;
                }
                default: {
                  var w = X.sipErrorCause(g.status_code);
                  h._registrationFailure(g, w);
                }
              }
          }
        });
        this._registering = !0, j.send();
      }
    }, {
      key: "unregister",
      value: function() {
        var h = this, p = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
        if (!this._registered) {
          E.debug("already unregistered");
          return;
        }
        this._registered = !1, this._registrationTimer !== null && (clearTimeout(this._registrationTimer), this._registrationTimer = null);
        var W = this._extraHeaders.slice();
        p.all ? W.push("Contact: *".concat(this._extraContactParams)) : W.push("Contact: ".concat(this._contact, ";expires=0").concat(this._extraContactParams)), W.push("Expires: 0");
        var j = new t.OutgoingRequest(F.REGISTER, this._registrar, this._ua, {
          to_uri: this._to_uri,
          call_id: this._call_id,
          cseq: this._cseq += 1
        }, W), P = new b(this._ua, j, {
          onRequestTimeout: function() {
            h._unregistered(null, F.causes.REQUEST_TIMEOUT);
          },
          onTransportError: function() {
            h._unregistered(null, F.causes.CONNECTION_ERROR);
          },
          // Increase the CSeq on authentication.
          onAuthenticated: function() {
            h._cseq += 1;
          },
          onReceiveResponse: function(k) {
            switch (!0) {
              case /^1[0-9]{2}$/.test(k.status_code):
                break;
              case /^2[0-9]{2}$/.test(k.status_code):
                h._unregistered(k);
                break;
              default: {
                var N = X.sipErrorCause(k.status_code);
                h._unregistered(k, N);
              }
            }
          }
        });
        P.send();
      }
    }, {
      key: "close",
      value: function() {
        this._registered && this.unregister();
      }
    }, {
      key: "onTransportClosed",
      value: function() {
        this._registering = !1, this._registrationTimer !== null && (clearTimeout(this._registrationTimer), this._registrationTimer = null), this._registered && (this._registered = !1, this._ua.unregistered({}));
      }
    }, {
      key: "_registrationFailure",
      value: function(h, p) {
        this._registering = !1, this._ua.registrationFailed({
          response: h || null,
          cause: p
        }), this._registered && (this._registered = !1, this._ua.unregistered({
          response: h || null,
          cause: p
        }));
      }
    }, {
      key: "_unregistered",
      value: function(h, p) {
        this._registering = !1, this._registered = !1, this._ua.unregistered({
          response: h || null,
          cause: p || null
        });
      }
    }, {
      key: "registered",
      get: function() {
        return this._registered;
      }
    }]), c;
  }(), Tn;
}
var Sn, Qs;
function El() {
  if (Qs) return Sn;
  Qs = 1;
  function U(b, E) {
    if (!(b instanceof E))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(b, E) {
    for (var i = 0; i < E.length; i++) {
      var c = E[i];
      c.enumerable = c.enumerable || !1, c.configurable = !0, "value" in c && (c.writable = !0), Object.defineProperty(b, c.key, c);
    }
  }
  function M(b, E, i) {
    return E && y(b.prototype, E), b;
  }
  var l = Re(), X = ct(), F = ht(), t = {
    onRequestTimeout: function() {
    },
    onTransportError: function() {
    },
    onSuccessResponse: function() {
    },
    onErrorResponse: function() {
    },
    onAuthenticated: function() {
    },
    onDialogError: function() {
    }
  };
  return Sn = /* @__PURE__ */ function() {
    function b(E, i, c) {
      U(this, b), this._dialog = E, this._ua = E._ua, this._request = i, this._eventHandlers = c, this._reattempt = !1, this._reattemptTimer = null;
      for (var o in t)
        Object.prototype.hasOwnProperty.call(t, o) && (this._eventHandlers[o] || (this._eventHandlers[o] = t[o]));
    }
    return M(b, [{
      key: "send",
      value: function() {
        var i = this, c = new F(this._ua, this._request, {
          onRequestTimeout: function() {
            i._eventHandlers.onRequestTimeout();
          },
          onTransportError: function() {
            i._eventHandlers.onTransportError();
          },
          onAuthenticated: function(p) {
            i._eventHandlers.onAuthenticated(p);
          },
          onReceiveResponse: function(p) {
            i._receiveResponse(p);
          }
        });
        if (c.send(), (this._request.method === l.INVITE || this._request.method === l.UPDATE && this._request.body) && c.clientTransaction.state !== X.C.STATUS_TERMINATED) {
          this._dialog.uac_pending_reply = !0;
          var o = function h() {
            (c.clientTransaction.state === X.C.STATUS_ACCEPTED || c.clientTransaction.state === X.C.STATUS_COMPLETED || c.clientTransaction.state === X.C.STATUS_TERMINATED) && (c.clientTransaction.removeListener("stateChanged", h), i._dialog.uac_pending_reply = !1);
          };
          c.clientTransaction.on("stateChanged", o);
        }
      }
    }, {
      key: "_receiveResponse",
      value: function(i) {
        var c = this;
        i.status_code === 408 || i.status_code === 481 ? this._eventHandlers.onDialogError(i) : i.method === l.INVITE && i.status_code === 491 ? this._reattempt ? i.status_code >= 200 && i.status_code < 300 ? this._eventHandlers.onSuccessResponse(i) : i.status_code >= 300 && this._eventHandlers.onErrorResponse(i) : (this._request.cseq = this._dialog.local_seqnum += 1, this._reattemptTimer = setTimeout(function() {
          c._dialog.isTerminated() || (c._reattempt = !0, c.send());
        }, 1e3)) : i.status_code >= 200 && i.status_code < 300 ? this._eventHandlers.onSuccessResponse(i) : i.status_code >= 300 && this._eventHandlers.onErrorResponse(i);
      }
    }, {
      key: "request",
      get: function() {
        return this._request;
      }
    }]), b;
  }(), Sn;
}
var Cn, Zs;
function Al() {
  if (Zs) return Cn;
  Zs = 1;
  function U(o, h) {
    if (!(o instanceof h))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(o, h) {
    for (var p = 0; p < h.length; p++) {
      var W = h[p];
      W.enumerable = W.enumerable || !1, W.configurable = !0, "value" in W && (W.writable = !0), Object.defineProperty(o, W.key, W);
    }
  }
  function M(o, h, p) {
    return h && y(o.prototype, h), p && y(o, p), o;
  }
  var l = Ie(), X = He(), F = Re(), t = ct(), b = El(), E = Oe(), i = new l("Dialog"), c = {
    // Dialog states.
    STATUS_EARLY: 1,
    STATUS_CONFIRMED: 2,
    STATUS_TERMINATED: 3
  };
  return Cn = /* @__PURE__ */ function() {
    M(o, null, [{
      key: "C",
      // Expose C object.
      get: function() {
        return c;
      }
    }]);
    function o(h, p, W) {
      var j = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : c.STATUS_CONFIRMED;
      if (U(this, o), this._owner = h, this._ua = h._ua, this._uac_pending_reply = !1, this._uas_pending_reply = !1, !p.hasHeader("contact"))
        return {
          error: "unable to create a Dialog without Contact header field"
        };
      p instanceof X.IncomingResponse && (j = p.status_code < 200 ? c.STATUS_EARLY : c.STATUS_CONFIRMED);
      var P = p.parseHeader("contact");
      W === "UAS" ? (this._id = {
        call_id: p.call_id,
        local_tag: p.to_tag,
        remote_tag: p.from_tag,
        toString: function() {
          return this.call_id + this.local_tag + this.remote_tag;
        }
      }, this._state = j, this._remote_seqnum = p.cseq, this._local_uri = p.parseHeader("to").uri, this._remote_uri = p.parseHeader("from").uri, this._remote_target = P.uri, this._route_set = p.getHeaders("record-route"), this._ack_seqnum = this._remote_seqnum) : W === "UAC" && (this._id = {
        call_id: p.call_id,
        local_tag: p.from_tag,
        remote_tag: p.to_tag,
        toString: function() {
          return this.call_id + this.local_tag + this.remote_tag;
        }
      }, this._state = j, this._local_seqnum = p.cseq, this._local_uri = p.parseHeader("from").uri, this._remote_uri = p.parseHeader("to").uri, this._remote_target = P.uri, this._route_set = p.getHeaders("record-route").reverse(), this._ack_seqnum = null), this._ua.newDialog(this), i.debug("new ".concat(W, " dialog created with status ").concat(this._state === c.STATUS_EARLY ? "EARLY" : "CONFIRMED"));
    }
    return M(o, [{
      key: "isTerminated",
      value: function() {
        return this._status === c.STATUS_TERMINATED;
      }
    }, {
      key: "update",
      value: function(p, W) {
        this._state = c.STATUS_CONFIRMED, i.debug("dialog ".concat(this._id.toString(), "  changed to CONFIRMED state")), W === "UAC" && (this._route_set = p.getHeaders("record-route").reverse());
      }
    }, {
      key: "terminate",
      value: function() {
        i.debug("dialog ".concat(this._id.toString(), " deleted")), this._ua.destroyDialog(this), this._state = c.STATUS_TERMINATED;
      }
    }, {
      key: "sendRequest",
      value: function(p) {
        var W = this, j = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, P = E.cloneArray(j.extraHeaders), g = E.cloneObject(j.eventHandlers), k = j.body || null, N = this._createRequest(p, P, k);
        g.onAuthenticated = function() {
          W._local_seqnum += 1;
        };
        var T = new b(this, N, g);
        return T.send(), N;
      }
    }, {
      key: "receiveRequest",
      value: function(p) {
        this._checkInDialogRequest(p) && (p.method === F.ACK && this._ack_seqnum !== null ? this._ack_seqnum = null : p.method === F.INVITE && (this._ack_seqnum = p.cseq), this._owner.receiveRequest(p));
      }
      // RFC 3261 12.2.1.1.
    }, {
      key: "_createRequest",
      value: function(p, W, j) {
        W = E.cloneArray(W), this._local_seqnum || (this._local_seqnum = Math.floor(Math.random() * 1e4));
        var P = p === F.CANCEL || p === F.ACK ? this._local_seqnum : this._local_seqnum += 1, g = new X.OutgoingRequest(p, this._remote_target, this._ua, {
          cseq: P,
          call_id: this._id.call_id,
          from_uri: this._local_uri,
          from_tag: this._id.local_tag,
          to_uri: this._remote_uri,
          to_tag: this._id.remote_tag,
          route_set: this._route_set
        }, W, j);
        return g;
      }
      // RFC 3261 12.2.2.
    }, {
      key: "_checkInDialogRequest",
      value: function(p) {
        var W = this;
        if (!this._remote_seqnum)
          this._remote_seqnum = p.cseq;
        else if (p.cseq < this._remote_seqnum)
          if (p.method === F.ACK) {
            if (this._ack_seqnum === null || p.cseq !== this._ack_seqnum)
              return !1;
          } else
            return p.reply(500), !1;
        else p.cseq > this._remote_seqnum && (this._remote_seqnum = p.cseq);
        if (p.method === F.INVITE || p.method === F.UPDATE && p.body) {
          if (this._uac_pending_reply === !0)
            p.reply(491);
          else if (this._uas_pending_reply === !0) {
            var j = (Math.random() * 10 | 0) + 1;
            return p.reply(500, null, ["Retry-After:".concat(j)]), !1;
          } else {
            this._uas_pending_reply = !0;
            var P = function g() {
              (p.server_transaction.state === t.C.STATUS_ACCEPTED || p.server_transaction.state === t.C.STATUS_COMPLETED || p.server_transaction.state === t.C.STATUS_TERMINATED) && (p.server_transaction.removeListener("stateChanged", g), W._uas_pending_reply = !1);
            };
            p.server_transaction.on("stateChanged", P);
          }
          p.hasHeader("contact") && p.server_transaction.on("stateChanged", function() {
            p.server_transaction.state === t.C.STATUS_ACCEPTED && (W._remote_target = p.parseHeader("contact").uri);
          });
        } else p.method === F.NOTIFY && p.hasHeader("contact") && p.server_transaction.on("stateChanged", function() {
          p.server_transaction.state === t.C.STATUS_COMPLETED && (W._remote_target = p.parseHeader("contact").uri);
        });
        return !0;
      }
    }, {
      key: "id",
      get: function() {
        return this._id;
      }
    }, {
      key: "local_seqnum",
      get: function() {
        return this._local_seqnum;
      },
      set: function(p) {
        this._local_seqnum = p;
      }
    }, {
      key: "owner",
      get: function() {
        return this._owner;
      }
    }, {
      key: "uac_pending_reply",
      get: function() {
        return this._uac_pending_reply;
      },
      set: function(p) {
        this._uac_pending_reply = p;
      }
    }, {
      key: "uas_pending_reply",
      get: function() {
        return this._uas_pending_reply;
      }
    }]), o;
  }(), Cn;
}
var Ot = { exports: {} }, ei;
function bl() {
  if (ei) return Ot.exports;
  ei = 1;
  function U(k) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(T) {
      return typeof T;
    } : U = function(T) {
      return T && typeof Symbol == "function" && T.constructor === Symbol && T !== Symbol.prototype ? "symbol" : typeof T;
    }, U(k);
  }
  function y(k, N) {
    if (!(k instanceof N))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(k, N) {
    for (var T = 0; T < N.length; T++) {
      var v = N[T];
      v.enumerable = v.enumerable || !1, v.configurable = !0, "value" in v && (v.writable = !0), Object.defineProperty(k, v.key, v);
    }
  }
  function l(k, N, T) {
    return N && M(k.prototype, N), k;
  }
  function X(k, N) {
    if (typeof N != "function" && N !== null)
      throw new TypeError("Super expression must either be null or a function");
    k.prototype = Object.create(N && N.prototype, { constructor: { value: k, writable: !0, configurable: !0 } }), N && F(k, N);
  }
  function F(k, N) {
    return F = Object.setPrototypeOf || function(v, w) {
      return v.__proto__ = w, v;
    }, F(k, N);
  }
  function t(k) {
    var N = i();
    return function() {
      var v = c(k), w;
      if (N) {
        var I = c(this).constructor;
        w = Reflect.construct(v, arguments, I);
      } else
        w = v.apply(this, arguments);
      return b(this, w);
    };
  }
  function b(k, N) {
    return N && (U(N) === "object" || typeof N == "function") ? N : E(k);
  }
  function E(k) {
    if (k === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return k;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(k) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(T) {
      return T.__proto__ || Object.getPrototypeOf(T);
    }, c(k);
  }
  var o = Be().EventEmitter, h = Ie(), p = Re(), W = Ge(), j = Oe(), P = new h("RTCSession:DTMF"), g = {
    MIN_DURATION: 70,
    MAX_DURATION: 6e3,
    DEFAULT_DURATION: 100,
    MIN_INTER_TONE_GAP: 50,
    DEFAULT_INTER_TONE_GAP: 500
  };
  return Ot.exports = /* @__PURE__ */ function(k) {
    X(T, k);
    var N = t(T);
    function T(v) {
      var w;
      return y(this, T), w = N.call(this), w._session = v, w._direction = null, w._tone = null, w._duration = null, w._request = null, w;
    }
    return l(T, [{
      key: "send",
      value: function(w) {
        var I = this, C = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
        if (w === void 0)
          throw new TypeError("Not enough arguments");
        if (this._direction = "outgoing", this._session.status !== this._session.C.STATUS_CONFIRMED && this._session.status !== this._session.C.STATUS_WAITING_FOR_ACK)
          throw new W.InvalidStateError(this._session.status);
        var O = j.cloneArray(C.extraHeaders);
        if (this.eventHandlers = j.cloneObject(C.eventHandlers), typeof w == "string")
          w = w.toUpperCase();
        else if (typeof w == "number")
          w = w.toString();
        else
          throw new TypeError("Invalid tone: ".concat(w));
        if (w.match(/^[0-9A-DR#*]$/))
          this._tone = w;
        else
          throw new TypeError("Invalid tone: ".concat(w));
        this._duration = C.duration, O.push("Content-Type: application/dtmf-relay");
        var K = "Signal=".concat(this._tone, `\r
`);
        K += "Duration=".concat(this._duration), this._session.newDTMF({
          originator: "local",
          dtmf: this,
          request: this._request
        }), this._session.sendRequest(p.INFO, {
          extraHeaders: O,
          eventHandlers: {
            onSuccessResponse: function(D) {
              I.emit("succeeded", {
                originator: "remote",
                response: D
              });
            },
            onErrorResponse: function(D) {
              I.eventHandlers.onFailed && I.eventHandlers.onFailed(), I.emit("failed", {
                originator: "remote",
                response: D
              });
            },
            onRequestTimeout: function() {
              I._session.onRequestTimeout();
            },
            onTransportError: function() {
              I._session.onTransportError();
            },
            onDialogError: function() {
              I._session.onDialogError();
            }
          },
          body: K
        });
      }
    }, {
      key: "init_incoming",
      value: function(w) {
        var I = /^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/, C = /^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;
        if (this._direction = "incoming", this._request = w, w.reply(200), w.body) {
          var O = w.body.split(`
`);
          O.length >= 1 && I.test(O[0]) && (this._tone = O[0].replace(I, "$2")), O.length >= 2 && C.test(O[1]) && (this._duration = parseInt(O[1].replace(C, "$2"), 10));
        }
        this._duration || (this._duration = g.DEFAULT_DURATION), this._tone ? this._session.newDTMF({
          originator: "remote",
          dtmf: this,
          request: w
        }) : P.debug("invalid INFO DTMF received, discarded");
      }
    }, {
      key: "tone",
      get: function() {
        return this._tone;
      }
    }, {
      key: "duration",
      get: function() {
        return this._duration;
      }
    }]), T;
  }(o), Ot.exports.C = g, Ot.exports;
}
var En, ti;
function Rl() {
  if (ti) return En;
  ti = 1;
  function U(j) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(g) {
      return typeof g;
    } : U = function(g) {
      return g && typeof Symbol == "function" && g.constructor === Symbol && g !== Symbol.prototype ? "symbol" : typeof g;
    }, U(j);
  }
  function y(j, P) {
    if (!(j instanceof P))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(j, P) {
    for (var g = 0; g < P.length; g++) {
      var k = P[g];
      k.enumerable = k.enumerable || !1, k.configurable = !0, "value" in k && (k.writable = !0), Object.defineProperty(j, k.key, k);
    }
  }
  function l(j, P, g) {
    return P && M(j.prototype, P), j;
  }
  function X(j, P) {
    if (typeof P != "function" && P !== null)
      throw new TypeError("Super expression must either be null or a function");
    j.prototype = Object.create(P && P.prototype, { constructor: { value: j, writable: !0, configurable: !0 } }), P && F(j, P);
  }
  function F(j, P) {
    return F = Object.setPrototypeOf || function(k, N) {
      return k.__proto__ = N, k;
    }, F(j, P);
  }
  function t(j) {
    var P = i();
    return function() {
      var k = c(j), N;
      if (P) {
        var T = c(this).constructor;
        N = Reflect.construct(k, arguments, T);
      } else
        N = k.apply(this, arguments);
      return b(this, N);
    };
  }
  function b(j, P) {
    return P && (U(P) === "object" || typeof P == "function") ? P : E(j);
  }
  function E(j) {
    if (j === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return j;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(j) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(g) {
      return g.__proto__ || Object.getPrototypeOf(g);
    }, c(j);
  }
  var o = Be().EventEmitter, h = Re(), p = Ge(), W = Oe();
  return En = /* @__PURE__ */ function(j) {
    X(g, j);
    var P = t(g);
    function g(k) {
      var N;
      return y(this, g), N = P.call(this), N._session = k, N._direction = null, N._contentType = null, N._body = null, N;
    }
    return l(g, [{
      key: "send",
      value: function(N, T) {
        var v = this, w = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
        if (this._direction = "outgoing", N === void 0)
          throw new TypeError("Not enough arguments");
        if (this._session.status !== this._session.C.STATUS_CONFIRMED && this._session.status !== this._session.C.STATUS_WAITING_FOR_ACK)
          throw new p.InvalidStateError(this._session.status);
        this._contentType = N, this._body = T;
        var I = W.cloneArray(w.extraHeaders);
        I.push("Content-Type: ".concat(N)), this._session.newInfo({
          originator: "local",
          info: this,
          request: this.request
        }), this._session.sendRequest(h.INFO, {
          extraHeaders: I,
          eventHandlers: {
            onSuccessResponse: function(O) {
              v.emit("succeeded", {
                originator: "remote",
                response: O
              });
            },
            onErrorResponse: function(O) {
              v.emit("failed", {
                originator: "remote",
                response: O
              });
            },
            onTransportError: function() {
              v._session.onTransportError();
            },
            onRequestTimeout: function() {
              v._session.onRequestTimeout();
            },
            onDialogError: function() {
              v._session.onDialogError();
            }
          },
          body: T
        });
      }
    }, {
      key: "init_incoming",
      value: function(N) {
        this._direction = "incoming", this.request = N, N.reply(200), this._contentType = N.hasHeader("Content-Type") ? N.getHeader("Content-Type").toLowerCase() : void 0, this._body = N.body, this._session.newInfo({
          originator: "remote",
          info: this,
          request: N
        });
      }
    }, {
      key: "contentType",
      get: function() {
        return this._contentType;
      }
    }, {
      key: "body",
      get: function() {
        return this._body;
      }
    }]), g;
  }(o), En;
}
var An, ni;
function wl() {
  if (ni) return An;
  ni = 1;
  function U(b, E) {
    if (!(b instanceof E))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(b, E) {
    for (var i = 0; i < E.length; i++) {
      var c = E[i];
      c.enumerable = c.enumerable || !1, c.configurable = !0, "value" in c && (c.writable = !0), Object.defineProperty(b, c.key, c);
    }
  }
  function M(b, E, i) {
    return E && y(b.prototype, E), b;
  }
  var l = Ie(), X = Re(), F = new l("RTCSession:ReferNotifier"), t = {
    event_type: "refer",
    body_type: "message/sipfrag;version=2.0",
    expires: 300
  };
  return An = /* @__PURE__ */ function() {
    function b(E, i, c) {
      U(this, b), this._session = E, this._id = i, this._expires = c || t.expires, this._active = !0, this.notify(100);
    }
    return M(b, [{
      key: "notify",
      value: function(i, c) {
        if (F.debug("notify()"), this._active !== !1) {
          c = c || X.REASON_PHRASE[i] || "";
          var o;
          i >= 200 ? o = "terminated;reason=noresource" : o = "active;expires=".concat(this._expires), this._session.sendRequest(X.NOTIFY, {
            extraHeaders: ["Event: ".concat(t.event_type, ";id=").concat(this._id), "Subscription-State: ".concat(o), "Content-Type: ".concat(t.body_type)],
            body: "SIP/2.0 ".concat(i, " ").concat(c),
            eventHandlers: {
              // If a negative response is received, subscription is canceled.
              onErrorResponse: function() {
                this._active = !1;
              }
            }
          });
        }
      }
    }]), b;
  }(), An;
}
var bn, ri;
function Il() {
  if (ri) return bn;
  ri = 1;
  function U(g) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(N) {
      return typeof N;
    } : U = function(N) {
      return N && typeof Symbol == "function" && N.constructor === Symbol && N !== Symbol.prototype ? "symbol" : typeof N;
    }, U(g);
  }
  function y(g, k) {
    if (!(g instanceof k))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(g, k) {
    for (var N = 0; N < k.length; N++) {
      var T = k[N];
      T.enumerable = T.enumerable || !1, T.configurable = !0, "value" in T && (T.writable = !0), Object.defineProperty(g, T.key, T);
    }
  }
  function l(g, k, N) {
    return k && M(g.prototype, k), g;
  }
  function X(g, k) {
    if (typeof k != "function" && k !== null)
      throw new TypeError("Super expression must either be null or a function");
    g.prototype = Object.create(k && k.prototype, { constructor: { value: g, writable: !0, configurable: !0 } }), k && F(g, k);
  }
  function F(g, k) {
    return F = Object.setPrototypeOf || function(T, v) {
      return T.__proto__ = v, T;
    }, F(g, k);
  }
  function t(g) {
    var k = i();
    return function() {
      var T = c(g), v;
      if (k) {
        var w = c(this).constructor;
        v = Reflect.construct(T, arguments, w);
      } else
        v = T.apply(this, arguments);
      return b(this, v);
    };
  }
  function b(g, k) {
    return k && (U(k) === "object" || typeof k == "function") ? k : E(g);
  }
  function E(g) {
    if (g === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return g;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(g) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(N) {
      return N.__proto__ || Object.getPrototypeOf(N);
    }, c(g);
  }
  var o = Be().EventEmitter, h = Ie(), p = Re(), W = Ue(), j = Oe(), P = new h("RTCSession:ReferSubscriber");
  return bn = /* @__PURE__ */ function(g) {
    X(N, g);
    var k = t(N);
    function N(T) {
      var v;
      return y(this, N), v = k.call(this), v._id = null, v._session = T, v;
    }
    return l(N, [{
      key: "sendRefer",
      value: function(v) {
        var w = this, I = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
        P.debug("sendRefer()");
        var C = j.cloneArray(I.extraHeaders), O = j.cloneObject(I.eventHandlers);
        for (var K in O)
          Object.prototype.hasOwnProperty.call(O, K) && this.on(K, O[K]);
        var Y = null;
        I.replaces && (Y = I.replaces._request.call_id, Y += ";to-tag=".concat(I.replaces._to_tag), Y += ";from-tag=".concat(I.replaces._from_tag), Y = encodeURIComponent(Y));
        var D = "Refer-To: <".concat(v).concat(Y ? "?Replaces=".concat(Y) : "", ">");
        if (C.push(D), !C.some(function(_) {
          return _.toLowerCase().startsWith("referred-by:");
        })) {
          var B = "Referred-By: <".concat(this._session._ua._configuration.uri._scheme, ":").concat(this._session._ua._configuration.uri._user, "@").concat(this._session._ua._configuration.uri._host, ">");
          C.push(B);
        }
        C.push("Contact: ".concat(this._session.contact));
        var d = this._session.sendRequest(p.REFER, {
          extraHeaders: C,
          eventHandlers: {
            onSuccessResponse: function(R) {
              w._requestSucceeded(R);
            },
            onErrorResponse: function(R) {
              w._requestFailed(R, p.causes.REJECTED);
            },
            onTransportError: function() {
              w._requestFailed(null, p.causes.CONNECTION_ERROR);
            },
            onRequestTimeout: function() {
              w._requestFailed(null, p.causes.REQUEST_TIMEOUT);
            },
            onDialogError: function() {
              w._requestFailed(null, p.causes.DIALOG_ERROR);
            }
          }
        });
        this._id = d.cseq;
      }
    }, {
      key: "receiveNotify",
      value: function(v) {
        if (P.debug("receiveNotify()"), !!v.body) {
          var w = W.parse(v.body.trim().split(`\r
`, 1)[0], "Status_Line");
          if (w === -1) {
            P.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(v.body, '"'));
            return;
          }
          switch (!0) {
            case /^100$/.test(w.status_code):
              this.emit("trying", {
                request: v,
                status_line: w
              });
              break;
            case /^1[0-9]{2}$/.test(w.status_code):
              this.emit("progress", {
                request: v,
                status_line: w
              });
              break;
            case /^2[0-9]{2}$/.test(w.status_code):
              this.emit("accepted", {
                request: v,
                status_line: w
              });
              break;
            default:
              this.emit("failed", {
                request: v,
                status_line: w
              });
              break;
          }
        }
      }
    }, {
      key: "_requestSucceeded",
      value: function(v) {
        P.debug("REFER succeeded"), P.debug('emit "requestSucceeded"'), this.emit("requestSucceeded", {
          response: v
        });
      }
    }, {
      key: "_requestFailed",
      value: function(v, w) {
        P.debug("REFER failed"), P.debug('emit "requestFailed"'), this.emit("requestFailed", {
          response: v || null,
          cause: w
        });
      }
    }, {
      key: "id",
      get: function() {
        return this._id;
      }
    }]), N;
  }(o), bn;
}
var Rn, si;
function Ol() {
  if (si) return Rn;
  si = 1;
  function U(A) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(V) {
      return typeof V;
    } : U = function(V) {
      return V && typeof Symbol == "function" && V.constructor === Symbol && V !== Symbol.prototype ? "symbol" : typeof V;
    }, U(A);
  }
  function y(A, G) {
    var V;
    if (typeof Symbol > "u" || A[Symbol.iterator] == null) {
      if (Array.isArray(A) || (V = M(A)) || G) {
        V && (A = V);
        var x = 0, u = function() {
        };
        return { s: u, n: function() {
          return x >= A.length ? { done: !0 } : { done: !1, value: A[x++] };
        }, e: function(z) {
          throw z;
        }, f: u };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var m = !0, L = !1, q;
    return { s: function() {
      V = A[Symbol.iterator]();
    }, n: function() {
      var z = V.next();
      return m = z.done, z;
    }, e: function(z) {
      L = !0, q = z;
    }, f: function() {
      try {
        !m && V.return != null && V.return();
      } finally {
        if (L) throw q;
      }
    } };
  }
  function M(A, G) {
    if (A) {
      if (typeof A == "string") return l(A, G);
      var V = Object.prototype.toString.call(A).slice(8, -1);
      if (V === "Object" && A.constructor && (V = A.constructor.name), V === "Map" || V === "Set") return Array.from(A);
      if (V === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V)) return l(A, G);
    }
  }
  function l(A, G) {
    (G == null || G > A.length) && (G = A.length);
    for (var V = 0, x = new Array(G); V < G; V++)
      x[V] = A[V];
    return x;
  }
  function X(A, G) {
    if (!(A instanceof G))
      throw new TypeError("Cannot call a class as a function");
  }
  function F(A, G) {
    for (var V = 0; V < G.length; V++) {
      var x = G[V];
      x.enumerable = x.enumerable || !1, x.configurable = !0, "value" in x && (x.writable = !0), Object.defineProperty(A, x.key, x);
    }
  }
  function t(A, G, V) {
    return G && F(A.prototype, G), V && F(A, V), A;
  }
  function b(A, G) {
    if (typeof G != "function" && G !== null)
      throw new TypeError("Super expression must either be null or a function");
    A.prototype = Object.create(G && G.prototype, { constructor: { value: A, writable: !0, configurable: !0 } }), G && E(A, G);
  }
  function E(A, G) {
    return E = Object.setPrototypeOf || function(x, u) {
      return x.__proto__ = u, x;
    }, E(A, G);
  }
  function i(A) {
    var G = h();
    return function() {
      var x = p(A), u;
      if (G) {
        var m = p(this).constructor;
        u = Reflect.construct(x, arguments, m);
      } else
        u = x.apply(this, arguments);
      return c(this, u);
    };
  }
  function c(A, G) {
    return G && (U(G) === "object" || typeof G == "function") ? G : o(A);
  }
  function o(A) {
    if (A === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return A;
  }
  function h() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function p(A) {
    return p = Object.setPrototypeOf ? Object.getPrototypeOf : function(V) {
      return V.__proto__ || Object.getPrototypeOf(V);
    }, p(A);
  }
  var W = Be().EventEmitter, j = gi(), P = Ie(), g = Re(), k = Ge(), N = ct(), T = Oe(), v = yi(), w = He(), I = Al(), C = ht(), O = bl(), K = Rl(), Y = wl(), D = Il(), B = Ve(), d = new P("RTCSession"), _ = {
    // RTCSession states.
    STATUS_NULL: 0,
    STATUS_INVITE_SENT: 1,
    STATUS_1XX_RECEIVED: 2,
    STATUS_INVITE_RECEIVED: 3,
    STATUS_WAITING_FOR_ANSWER: 4,
    STATUS_ANSWERED: 5,
    STATUS_WAITING_FOR_ACK: 6,
    STATUS_CANCELED: 7,
    STATUS_TERMINATED: 8,
    STATUS_CONFIRMED: 9
  }, R = ["audio", "video"];
  return Rn = /* @__PURE__ */ function(A) {
    b(V, A);
    var G = i(V);
    t(V, null, [{
      key: "C",
      /**
       * Expose C object.
       */
      get: function() {
        return _;
      }
    }]);
    function V(x) {
      var u;
      return X(this, V), d.debug("new"), u = G.call(this), u._id = null, u._ua = x, u._status = _.STATUS_NULL, u._dialog = null, u._earlyDialogs = {}, u._contact = null, u._from_tag = null, u._to_tag = null, u._connection = null, u._connectionPromiseQueue = Promise.resolve(), u._request = null, u._is_canceled = !1, u._cancel_reason = "", u._is_confirmed = !1, u._late_sdp = !1, u._rtcOfferConstraints = null, u._rtcAnswerConstraints = null, u._localMediaStream = null, u._localMediaStreamLocallyGenerated = !1, u._rtcReady = !0, u._iceReady = !1, u._timers = {
        ackTimer: null,
        expiresTimer: null,
        invite2xxTimer: null,
        userNoAnswerTimer: null
      }, u._direction = null, u._local_identity = null, u._remote_identity = null, u._start_time = null, u._end_time = null, u._tones = null, u._audioMuted = !1, u._videoMuted = !1, u._localHold = !1, u._remoteHold = !1, u._sessionTimers = {
        enabled: u._ua.configuration.session_timers,
        refreshMethod: u._ua.configuration.session_timers_refresh_method,
        defaultExpires: g.SESSION_EXPIRES,
        currentExpires: null,
        running: !1,
        refresher: !1,
        timer: null
        // A setTimeout.
      }, u._referSubscribers = {}, u._data = {}, u;
    }
    return t(V, [{
      key: "isInProgress",
      value: function() {
        switch (this._status) {
          case _.STATUS_NULL:
          case _.STATUS_INVITE_SENT:
          case _.STATUS_1XX_RECEIVED:
          case _.STATUS_INVITE_RECEIVED:
          case _.STATUS_WAITING_FOR_ANSWER:
            return !0;
          default:
            return !1;
        }
      }
    }, {
      key: "isEstablished",
      value: function() {
        switch (this._status) {
          case _.STATUS_ANSWERED:
          case _.STATUS_WAITING_FOR_ACK:
          case _.STATUS_CONFIRMED:
            return !0;
          default:
            return !1;
        }
      }
    }, {
      key: "isEnded",
      value: function() {
        switch (this._status) {
          case _.STATUS_CANCELED:
          case _.STATUS_TERMINATED:
            return !0;
          default:
            return !1;
        }
      }
    }, {
      key: "isMuted",
      value: function() {
        return {
          audio: this._audioMuted,
          video: this._videoMuted
        };
      }
    }, {
      key: "isOnHold",
      value: function() {
        return {
          local: this._localHold,
          remote: this._remoteHold
        };
      }
    }, {
      key: "connect",
      value: function(u) {
        var m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, L = arguments.length > 2 ? arguments[2] : void 0;
        d.debug("connect()");
        var q = u, $ = T.cloneObject(m.eventHandlers), z = T.cloneArray(m.extraHeaders), ee = T.cloneObject(m.mediaConstraints, {
          audio: !0,
          video: !0
        }), Z = m.mediaStream || null, re = T.cloneObject(m.pcConfig, {
          iceServers: []
        }), se = m.rtcConstraints || null, ne = m.rtcOfferConstraints || null;
        if (this._rtcOfferConstraints = ne, this._rtcAnswerConstraints = m.rtcAnswerConstraints || null, this._data = m.data || this._data, u === void 0)
          throw new TypeError("Not enough arguments");
        if (this._status !== _.STATUS_NULL)
          throw new k.InvalidStateError(this._status);
        if (!window.RTCPeerConnection)
          throw new k.NotSupportedError("WebRTC not supported");
        if (u = this._ua.normalizeTarget(u), !u)
          throw new TypeError("Invalid target: ".concat(q));
        this._sessionTimers.enabled && T.isDecimal(m.sessionTimersExpires) && (m.sessionTimersExpires >= g.MIN_SESSION_EXPIRES ? this._sessionTimers.defaultExpires = m.sessionTimersExpires : this._sessionTimers.defaultExpires = g.SESSION_EXPIRES);
        for (var he in $)
          Object.prototype.hasOwnProperty.call($, he) && this.on(he, $[he]);
        this._from_tag = T.newTag();
        var pe = m.anonymous || !1, Te = {
          from_tag: this._from_tag
        };
        this._contact = this._ua.contact.toString({
          anonymous: pe,
          outbound: !0
        }), pe ? (Te.from_display_name = "Anonymous", Te.from_uri = new B("sip", "anonymous", "anonymous.invalid"), z.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())), z.push("Privacy: id")) : m.fromUserName && (Te.from_uri = new B("sip", m.fromUserName, this._ua.configuration.uri.host), z.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))), m.fromDisplayName && (Te.from_display_name = m.fromDisplayName), z.push("Contact: ".concat(this._contact)), z.push("Content-Type: application/sdp"), this._sessionTimers.enabled && z.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher ? ";refresher=uac" : "")), this._request = new w.InitialOutgoingInviteRequest(u, this._ua, Te, z), this._id = this._request.call_id + this._from_tag, this._createRTCConnection(re, se), this._direction = "outgoing", this._local_identity = this._request.from, this._remote_identity = this._request.to, L && L(this), this._newRTCSession("local", this._request), this._sendInitialRequest(ee, ne, Z);
      }
    }, {
      key: "init_incoming",
      value: function(u, m) {
        var L = this;
        d.debug("init_incoming()");
        var q, $ = u.hasHeader("Content-Type") ? u.getHeader("Content-Type").toLowerCase() : void 0;
        if (u.body && $ !== "application/sdp") {
          u.reply(415);
          return;
        }
        if (this._status = _.STATUS_INVITE_RECEIVED, this._from_tag = u.from_tag, this._id = u.call_id + this._from_tag, this._request = u, this._contact = this._ua.contact.toString(), u.hasHeader("expires") && (q = u.getHeader("expires") * 1e3), u.to_tag = T.newTag(), !this._createDialog(u, "UAS", !0)) {
          u.reply(500, "Missing Contact header field");
          return;
        }
        u.body ? this._late_sdp = !1 : this._late_sdp = !0, this._status = _.STATUS_WAITING_FOR_ANSWER, this._timers.userNoAnswerTimer = setTimeout(function() {
          u.reply(408), L._failed("local", null, g.causes.NO_ANSWER);
        }, this._ua.configuration.no_answer_timeout), q && (this._timers.expiresTimer = setTimeout(function() {
          L._status === _.STATUS_WAITING_FOR_ANSWER && (u.reply(487), L._failed("system", null, g.causes.EXPIRES));
        }, q)), this._direction = "incoming", this._local_identity = u.to, this._remote_identity = u.from, m && m(this), this._newRTCSession("remote", u), this._status !== _.STATUS_TERMINATED && (u.reply(180, null, ["Contact: ".concat(this._contact)]), this._progress("local", null));
      }
      /**
       * Answer the call.
       */
    }, {
      key: "answer",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
        d.debug("answer()");
        var L = this._request, q = T.cloneArray(m.extraHeaders), $ = T.cloneObject(m.mediaConstraints), z = m.mediaStream || null, ee = T.cloneObject(m.pcConfig, {
          iceServers: []
        }), Z = m.rtcConstraints || null, re = m.rtcAnswerConstraints || null, se = T.cloneObject(m.rtcOfferConstraints), ne, he = !1, pe = !1, Te = !1, ue = !1;
        if (this._rtcAnswerConstraints = re, this._rtcOfferConstraints = m.rtcOfferConstraints || null, this._data = m.data || this._data, this._direction !== "incoming")
          throw new k.NotSupportedError('"answer" not supported for outgoing RTCSession');
        if (this._status !== _.STATUS_WAITING_FOR_ANSWER)
          throw new k.InvalidStateError(this._status);
        if (this._sessionTimers.enabled && T.isDecimal(m.sessionTimersExpires) && (m.sessionTimersExpires >= g.MIN_SESSION_EXPIRES ? this._sessionTimers.defaultExpires = m.sessionTimersExpires : this._sessionTimers.defaultExpires = g.SESSION_EXPIRES), this._status = _.STATUS_ANSWERED, !this._createDialog(L, "UAS")) {
          L.reply(500, "Error creating dialog");
          return;
        }
        clearTimeout(this._timers.userNoAnswerTimer), q.unshift("Contact: ".concat(this._contact));
        var ae = L.parseSDP();
        Array.isArray(ae.media) || (ae.media = [ae.media]);
        var ce = y(ae.media), _e;
        try {
          for (ce.s(); !(_e = ce.n()).done; ) {
            var ve = _e.value;
            ve.type === "audio" && (he = !0, (!ve.direction || ve.direction === "sendrecv") && (Te = !0)), ve.type === "video" && (pe = !0, (!ve.direction || ve.direction === "sendrecv") && (ue = !0));
          }
        } catch (ye) {
          ce.e(ye);
        } finally {
          ce.f();
        }
        if (z && $.audio === !1) {
          ne = z.getAudioTracks();
          var Se = y(ne), me;
          try {
            for (Se.s(); !(me = Se.n()).done; ) {
              var Me = me.value;
              z.removeTrack(Me);
            }
          } catch (ye) {
            Se.e(ye);
          } finally {
            Se.f();
          }
        }
        if (z && $.video === !1) {
          ne = z.getVideoTracks();
          var we = y(ne), Qe;
          try {
            for (we.s(); !(Qe = we.n()).done; ) {
              var Ze = Qe.value;
              z.removeTrack(Ze);
            }
          } catch (ye) {
            we.e(ye);
          } finally {
            we.f();
          }
        }
        !z && $.audio === void 0 && ($.audio = Te), !z && $.video === void 0 && ($.video = ue), !z && !he && !se.offerToReceiveAudio && ($.audio = !1), !z && !pe && !se.offerToReceiveVideo && ($.video = !1), this._createRTCConnection(ee, Z), Promise.resolve().then(function() {
          if (z)
            return z;
          if ($.audio || $.video)
            return u._localMediaStreamLocallyGenerated = !0, navigator.mediaDevices.getUserMedia($).catch(function(ye) {
              throw u._status === _.STATUS_TERMINATED ? new Error("terminated") : (L.reply(480), u._failed("local", null, g.causes.USER_DENIED_MEDIA_ACCESS), d.warn('emit "getusermediafailed" [error:%o]', ye), u.emit("getusermediafailed", ye), new Error("getUserMedia() failed"));
            });
        }).then(function(ye) {
          if (u._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          u._localMediaStream = ye, ye && ye.getTracks().forEach(function(qe) {
            u._connection.addTrack(qe, ye);
          });
        }).then(function() {
          if (!u._late_sdp) {
            var ye = {
              originator: "remote",
              type: "offer",
              sdp: L.body
            };
            d.debug('emit "sdp"'), u.emit("sdp", ye);
            var qe = new RTCSessionDescription({
              type: "offer",
              sdp: ye.sdp
            });
            return u._connectionPromiseQueue = u._connectionPromiseQueue.then(function() {
              return u._connection.setRemoteDescription(qe);
            }).catch(function(je) {
              throw L.reply(488), u._failed("system", null, g.causes.WEBRTC_ERROR), d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', je), u.emit("peerconnection:setremotedescriptionfailed", je), new Error("peerconnection.setRemoteDescription() failed");
            }), u._connectionPromiseQueue;
          }
        }).then(function() {
          if (u._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          return u._connecting(L), u._late_sdp ? u._createLocalDescription("offer", u._rtcOfferConstraints).catch(function() {
            throw L.reply(500), new Error("_createLocalDescription() failed");
          }) : u._createLocalDescription("answer", re).catch(function() {
            throw L.reply(500), new Error("_createLocalDescription() failed");
          });
        }).then(function(ye) {
          if (u._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          u._handleSessionTimersInIncomingRequest(L, q), L.reply(200, null, q, ye, function() {
            u._status = _.STATUS_WAITING_FOR_ACK, u._setInvite2xxTimer(L, ye), u._setACKTimer(), u._accepted("local");
          }, function() {
            u._failed("system", null, g.causes.CONNECTION_ERROR);
          });
        }).catch(function(ye) {
          u._status !== _.STATUS_TERMINATED && d.warn(ye);
        });
      }
      /**
       * Terminate the call.
       */
    }, {
      key: "terminate",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
        d.debug("terminate()");
        var L = m.cause || g.causes.BYE, q = T.cloneArray(m.extraHeaders), $ = m.body, z, ee = m.status_code, Z = m.reason_phrase;
        if (this._status === _.STATUS_TERMINATED)
          throw new k.InvalidStateError(this._status);
        switch (this._status) {
          // - UAC -
          case _.STATUS_NULL:
          case _.STATUS_INVITE_SENT:
          case _.STATUS_1XX_RECEIVED:
            if (d.debug("canceling session"), ee && (ee < 200 || ee >= 700))
              throw new TypeError("Invalid status_code: ".concat(ee));
            ee && (Z = Z || g.REASON_PHRASE[ee] || "", z = "SIP ;cause=".concat(ee, ' ;text="').concat(Z, '"')), this._status === _.STATUS_NULL || this._status === _.STATUS_INVITE_SENT ? (this._is_canceled = !0, this._cancel_reason = z) : this._status === _.STATUS_1XX_RECEIVED && this._request.cancel(z), this._status = _.STATUS_CANCELED, this._failed("local", null, g.causes.CANCELED);
            break;
          // - UAS -
          case _.STATUS_WAITING_FOR_ANSWER:
          case _.STATUS_ANSWERED:
            if (d.debug("rejecting session"), ee = ee || 480, ee < 300 || ee >= 700)
              throw new TypeError("Invalid status_code: ".concat(ee));
            this._request.reply(ee, Z, q, $), this._failed("local", null, g.causes.REJECTED);
            break;
          case _.STATUS_WAITING_FOR_ACK:
          case _.STATUS_CONFIRMED:
            if (d.debug("terminating session"), Z = m.reason_phrase || g.REASON_PHRASE[ee] || "", ee && (ee < 200 || ee >= 700))
              throw new TypeError("Invalid status_code: ".concat(ee));
            if (ee && q.push("Reason: SIP ;cause=".concat(ee, '; text="').concat(Z, '"')), this._status === _.STATUS_WAITING_FOR_ACK && this._direction === "incoming" && this._request.server_transaction.state !== N.C.STATUS_TERMINATED) {
              var re = this._dialog;
              this.receiveRequest = function(se) {
                var ne = se.method;
                ne === g.ACK && (u.sendRequest(g.BYE, {
                  extraHeaders: q,
                  body: $
                }), re.terminate());
              }, this._request.server_transaction.on("stateChanged", function() {
                u._request.server_transaction.state === N.C.STATUS_TERMINATED && (u.sendRequest(g.BYE, {
                  extraHeaders: q,
                  body: $
                }), re.terminate());
              }), this._ended("local", null, L), this._dialog = re, this._ua.newDialog(re);
            } else
              this.sendRequest(g.BYE, {
                extraHeaders: q,
                body: $
              }), this._ended("local", null, L);
        }
      }
    }, {
      key: "sendDTMF",
      value: function(u) {
        var m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
        d.debug("sendDTMF() | tones: %s", u);
        var L = 0, q = m.duration || null, $ = m.interToneGap || null, z = m.transportType || g.DTMF_TRANSPORT.INFO;
        if (u === void 0)
          throw new TypeError("Not enough arguments");
        if (this._status !== _.STATUS_CONFIRMED && this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_1XX_RECEIVED)
          throw new k.InvalidStateError(this._status);
        if (z !== g.DTMF_TRANSPORT.INFO && z !== g.DTMF_TRANSPORT.RFC2833)
          throw new TypeError("invalid transportType: ".concat(z));
        if (typeof u == "number" && (u = u.toString()), !u || typeof u != "string" || !u.match(/^[0-9A-DR#*,]+$/i))
          throw new TypeError("Invalid tones: ".concat(u));
        if (q && !T.isDecimal(q))
          throw new TypeError("Invalid tone duration: ".concat(q));
        if (q ? q < O.C.MIN_DURATION ? (d.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(O.C.MIN_DURATION, " milliseconds")), q = O.C.MIN_DURATION) : q > O.C.MAX_DURATION ? (d.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(O.C.MAX_DURATION, " milliseconds")), q = O.C.MAX_DURATION) : q = Math.abs(q) : q = O.C.DEFAULT_DURATION, m.duration = q, $ && !T.isDecimal($))
          throw new TypeError("Invalid interToneGap: ".concat($));
        if ($ ? $ < O.C.MIN_INTER_TONE_GAP ? (d.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(O.C.MIN_INTER_TONE_GAP, " milliseconds")), $ = O.C.MIN_INTER_TONE_GAP) : $ = Math.abs($) : $ = O.C.DEFAULT_INTER_TONE_GAP, z === g.DTMF_TRANSPORT.RFC2833) {
          var ee = this._getDTMFRTPSender();
          ee && (u = ee.toneBuffer + u, ee.insertDTMF(u, q, $));
          return;
        }
        if (this._tones) {
          this._tones += u;
          return;
        }
        this._tones = u, Z.call(this);
        function Z() {
          var re = this, se;
          if (this._status === _.STATUS_TERMINATED || !this._tones || L >= this._tones.length) {
            this._tones = null;
            return;
          }
          var ne = this._tones[L];
          if (L += 1, ne === ",")
            se = 2e3;
          else {
            var he = new O(this);
            m.eventHandlers = {
              onFailed: function() {
                re._tones = null;
              }
            }, he.send(ne, m), se = q + $;
          }
          setTimeout(Z.bind(this), se);
        }
      }
    }, {
      key: "sendInfo",
      value: function(u, m) {
        var L = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
        if (d.debug("sendInfo()"), this._status !== _.STATUS_CONFIRMED && this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_1XX_RECEIVED)
          throw new k.InvalidStateError(this._status);
        var q = new K(this);
        q.send(u, m, L);
      }
      /**
       * Mute
       */
    }, {
      key: "mute",
      value: function() {
        var u = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
          audio: !0,
          video: !1
        };
        d.debug("mute()");
        var m = !1, L = !1;
        this._audioMuted === !1 && u.audio && (m = !0, this._audioMuted = !0, this._toggleMuteAudio(!0)), this._videoMuted === !1 && u.video && (L = !0, this._videoMuted = !0, this._toggleMuteVideo(!0)), (m === !0 || L === !0) && this._onmute({
          audio: m,
          video: L
        });
      }
      /**
       * Unmute
       */
    }, {
      key: "unmute",
      value: function() {
        var u = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
          audio: !0,
          video: !0
        };
        d.debug("unmute()");
        var m = !1, L = !1;
        this._audioMuted === !0 && u.audio && (m = !0, this._audioMuted = !1, this._localHold === !1 && this._toggleMuteAudio(!1)), this._videoMuted === !0 && u.video && (L = !0, this._videoMuted = !1, this._localHold === !1 && this._toggleMuteVideo(!1)), (m === !0 || L === !0) && this._onunmute({
          audio: m,
          video: L
        });
      }
      /**
       * Hold
       */
    }, {
      key: "hold",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, L = arguments.length > 1 ? arguments[1] : void 0;
        if (d.debug("hold()"), this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_CONFIRMED || this._localHold === !0 || !this._isReadyToReOffer())
          return !1;
        this._localHold = !0, this._onhold("local");
        var q = {
          succeeded: function() {
            L && L();
          },
          failed: function() {
            u.terminate({
              cause: g.causes.WEBRTC_ERROR,
              status_code: 500,
              reason_phrase: "Hold Failed"
            });
          }
        };
        return m.useUpdate ? this._sendUpdate({
          sdpOffer: !0,
          eventHandlers: q,
          extraHeaders: m.extraHeaders
        }) : this._sendReinvite({
          eventHandlers: q,
          extraHeaders: m.extraHeaders
        }), !0;
      }
    }, {
      key: "unhold",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, L = arguments.length > 1 ? arguments[1] : void 0;
        if (d.debug("unhold()"), this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_CONFIRMED || this._localHold === !1 || !this._isReadyToReOffer())
          return !1;
        this._localHold = !1, this._onunhold("local");
        var q = {
          succeeded: function() {
            L && L();
          },
          failed: function() {
            u.terminate({
              cause: g.causes.WEBRTC_ERROR,
              status_code: 500,
              reason_phrase: "Unhold Failed"
            });
          }
        };
        return m.useUpdate ? this._sendUpdate({
          sdpOffer: !0,
          eventHandlers: q,
          extraHeaders: m.extraHeaders
        }) : this._sendReinvite({
          eventHandlers: q,
          extraHeaders: m.extraHeaders
        }), !0;
      }
    }, {
      key: "renegotiate",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, L = arguments.length > 1 ? arguments[1] : void 0;
        d.debug("renegotiate()");
        var q = m.rtcOfferConstraints || null;
        if (this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_CONFIRMED || !this._isReadyToReOffer())
          return !1;
        var $ = {
          succeeded: function() {
            L && L();
          },
          failed: function() {
            u.terminate({
              cause: g.causes.WEBRTC_ERROR,
              status_code: 500,
              reason_phrase: "Media Renegotiation Failed"
            });
          }
        };
        return this._setLocalMediaStatus(), m.useUpdate ? this._sendUpdate({
          sdpOffer: !0,
          eventHandlers: $,
          rtcOfferConstraints: q,
          extraHeaders: m.extraHeaders
        }) : this._sendReinvite({
          eventHandlers: $,
          rtcOfferConstraints: q,
          extraHeaders: m.extraHeaders
        }), !0;
      }
      /**
       * Refer
       */
    }, {
      key: "refer",
      value: function(u, m) {
        var L = this;
        d.debug("refer()");
        var q = u;
        if (this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_CONFIRMED)
          return !1;
        if (u = this._ua.normalizeTarget(u), !u)
          throw new TypeError("Invalid target: ".concat(q));
        var $ = new D(this);
        $.sendRefer(u, m);
        var z = $.id;
        return this._referSubscribers[z] = $, $.on("requestFailed", function() {
          delete L._referSubscribers[z];
        }), $.on("accepted", function() {
          delete L._referSubscribers[z];
        }), $.on("failed", function() {
          delete L._referSubscribers[z];
        }), $;
      }
      /**
       * Send a generic in-dialog Request
       */
    }, {
      key: "sendRequest",
      value: function(u, m) {
        return d.debug("sendRequest()"), this._dialog.sendRequest(u, m);
      }
      /**
       * In dialog Request Reception
       */
    }, {
      key: "receiveRequest",
      value: function(u) {
        var m = this;
        if (d.debug("receiveRequest()"), u.method === g.CANCEL)
          (this._status === _.STATUS_WAITING_FOR_ANSWER || this._status === _.STATUS_ANSWERED) && (this._status = _.STATUS_CANCELED, this._request.reply(487), this._failed("remote", u, g.causes.CANCELED));
        else
          switch (u.method) {
            case g.ACK:
              if (this._status !== _.STATUS_WAITING_FOR_ACK)
                return;
              if (this._status = _.STATUS_CONFIRMED, clearTimeout(this._timers.ackTimer), clearTimeout(this._timers.invite2xxTimer), this._late_sdp) {
                if (!u.body) {
                  this.terminate({
                    cause: g.causes.MISSING_SDP,
                    status_code: 400
                  });
                  break;
                }
                var L = {
                  originator: "remote",
                  type: "answer",
                  sdp: u.body
                };
                d.debug('emit "sdp"'), this.emit("sdp", L);
                var q = new RTCSessionDescription({
                  type: "answer",
                  sdp: L.sdp
                });
                this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
                  return m._connection.setRemoteDescription(q);
                }).then(function() {
                  m._is_confirmed || m._confirmed("remote", u);
                }).catch(function(z) {
                  m.terminate({
                    cause: g.causes.BAD_MEDIA_DESCRIPTION,
                    status_code: 488
                  }), d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', z), m.emit("peerconnection:setremotedescriptionfailed", z);
                });
              } else this._is_confirmed || this._confirmed("remote", u);
              break;
            case g.BYE:
              this._status === _.STATUS_CONFIRMED || this._status === _.STATUS_WAITING_FOR_ACK ? (u.reply(200), this._ended("remote", u, g.causes.BYE)) : this._status === _.STATUS_INVITE_RECEIVED || this._status === _.STATUS_WAITING_FOR_ANSWER ? (u.reply(200), this._request.reply(487, "BYE Received"), this._ended("remote", u, g.causes.BYE)) : u.reply(403, "Wrong Status");
              break;
            case g.INVITE:
              this._status === _.STATUS_CONFIRMED ? u.hasHeader("replaces") ? this._receiveReplaces(u) : this._receiveReinvite(u) : u.reply(403, "Wrong Status");
              break;
            case g.INFO:
              if (this._status === _.STATUS_1XX_RECEIVED || this._status === _.STATUS_WAITING_FOR_ANSWER || this._status === _.STATUS_ANSWERED || this._status === _.STATUS_WAITING_FOR_ACK || this._status === _.STATUS_CONFIRMED) {
                var $ = u.hasHeader("Content-Type") ? u.getHeader("Content-Type").toLowerCase() : void 0;
                $ && $.match(/^application\/dtmf-relay/i) ? new O(this).init_incoming(u) : $ !== void 0 ? new K(this).init_incoming(u) : u.reply(415);
              } else
                u.reply(403, "Wrong Status");
              break;
            case g.UPDATE:
              this._status === _.STATUS_CONFIRMED ? this._receiveUpdate(u) : u.reply(403, "Wrong Status");
              break;
            case g.REFER:
              this._status === _.STATUS_CONFIRMED ? this._receiveRefer(u) : u.reply(403, "Wrong Status");
              break;
            case g.NOTIFY:
              this._status === _.STATUS_CONFIRMED ? this._receiveNotify(u) : u.reply(403, "Wrong Status");
              break;
            default:
              u.reply(501);
          }
      }
      /**
       * Session Callbacks
       */
    }, {
      key: "onTransportError",
      value: function() {
        d.warn("onTransportError()"), this._status !== _.STATUS_TERMINATED && this.terminate({
          status_code: 500,
          reason_phrase: g.causes.CONNECTION_ERROR,
          cause: g.causes.CONNECTION_ERROR
        });
      }
    }, {
      key: "onRequestTimeout",
      value: function() {
        d.warn("onRequestTimeout()"), this._status !== _.STATUS_TERMINATED && this.terminate({
          status_code: 408,
          reason_phrase: g.causes.REQUEST_TIMEOUT,
          cause: g.causes.REQUEST_TIMEOUT
        });
      }
    }, {
      key: "onDialogError",
      value: function() {
        d.warn("onDialogError()"), this._status !== _.STATUS_TERMINATED && this.terminate({
          status_code: 500,
          reason_phrase: g.causes.DIALOG_ERROR,
          cause: g.causes.DIALOG_ERROR
        });
      }
      // Called from DTMF handler.
    }, {
      key: "newDTMF",
      value: function(u) {
        d.debug("newDTMF()"), this.emit("newDTMF", u);
      }
      // Called from Info handler.
    }, {
      key: "newInfo",
      value: function(u) {
        d.debug("newInfo()"), this.emit("newInfo", u);
      }
      /**
       * Check if RTCSession is ready for an outgoing re-INVITE or UPDATE with SDP.
       */
    }, {
      key: "_isReadyToReOffer",
      value: function() {
        return this._rtcReady ? this._dialog ? this._dialog.uac_pending_reply === !0 || this._dialog.uas_pending_reply === !0 ? (d.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"), !1) : !0 : (d.debug("_isReadyToReOffer() | session not established yet"), !1) : (d.debug("_isReadyToReOffer() | internal WebRTC status not ready"), !1);
      }
    }, {
      key: "_close",
      value: function() {
        if (d.debug("close()"), this._localMediaStream && this._localMediaStreamLocallyGenerated && (d.debug("close() | closing local MediaStream"), T.closeMediaStream(this._localMediaStream)), this._status !== _.STATUS_TERMINATED) {
          if (this._status = _.STATUS_TERMINATED, this._connection)
            try {
              this._connection.close();
            } catch (q) {
              d.warn("close() | error closing the RTCPeerConnection: %o", q);
            }
          for (var u in this._timers)
            Object.prototype.hasOwnProperty.call(this._timers, u) && clearTimeout(this._timers[u]);
          clearTimeout(this._sessionTimers.timer), this._dialog && (this._dialog.terminate(), delete this._dialog);
          for (var m in this._earlyDialogs)
            Object.prototype.hasOwnProperty.call(this._earlyDialogs, m) && (this._earlyDialogs[m].terminate(), delete this._earlyDialogs[m]);
          for (var L in this._referSubscribers)
            Object.prototype.hasOwnProperty.call(this._referSubscribers, L) && delete this._referSubscribers[L];
          this._ua.destroyRTCSession(this);
        }
      }
      /**
       * Private API.
       */
      /**
       * RFC3261 13.3.1.4
       * Response retransmissions cannot be accomplished by transaction layer
       *  since it is destroyed when receiving the first 2xx answer
       */
    }, {
      key: "_setInvite2xxTimer",
      value: function(u, m) {
        var L = v.T1;
        function q() {
          this._status === _.STATUS_WAITING_FOR_ACK && (u.reply(200, null, ["Contact: ".concat(this._contact)], m), L < v.T2 && (L = L * 2, L > v.T2 && (L = v.T2)), this._timers.invite2xxTimer = setTimeout(q.bind(this), L));
        }
        this._timers.invite2xxTimer = setTimeout(q.bind(this), L);
      }
      /**
       * RFC3261 14.2
       * If a UAS generates a 2xx response and never receives an ACK,
       *  it SHOULD generate a BYE to terminate the dialog.
       */
    }, {
      key: "_setACKTimer",
      value: function() {
        var u = this;
        this._timers.ackTimer = setTimeout(function() {
          u._status === _.STATUS_WAITING_FOR_ACK && (d.debug("no ACK received, terminating the session"), clearTimeout(u._timers.invite2xxTimer), u.sendRequest(g.BYE), u._ended("remote", null, g.causes.NO_ACK));
        }, v.TIMER_H);
      }
    }, {
      key: "_createRTCConnection",
      value: function(u, m) {
        var L = this;
        this._connection = new RTCPeerConnection(u, m), this._connection.addEventListener("iceconnectionstatechange", function() {
          var q = L._connection.iceConnectionState;
          q === "failed" && L.terminate({
            cause: g.causes.RTP_TIMEOUT,
            status_code: 408,
            reason_phrase: g.causes.RTP_TIMEOUT
          });
        }), d.debug('emit "peerconnection"'), this.emit("peerconnection", {
          peerconnection: this._connection
        });
      }
    }, {
      key: "_createLocalDescription",
      value: function(u, m) {
        var L = this;
        if (d.debug("createLocalDescription()"), u !== "offer" && u !== "answer") throw new Error('createLocalDescription() | invalid type "'.concat(u, '"'));
        var q = this._connection;
        return this._rtcReady = !1, Promise.resolve().then(function() {
          return u === "offer" ? q.createOffer(m).catch(function($) {
            return d.warn('emit "peerconnection:createofferfailed" [error:%o]', $), L.emit("peerconnection:createofferfailed", $), Promise.reject($);
          }) : q.createAnswer(m).catch(function($) {
            return d.warn('emit "peerconnection:createanswerfailed" [error:%o]', $), L.emit("peerconnection:createanswerfailed", $), Promise.reject($);
          });
        }).then(function($) {
          return q.setLocalDescription($).catch(function(z) {
            return L._rtcReady = !0, d.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]', z), L.emit("peerconnection:setlocaldescriptionfailed", z), Promise.reject(z);
          });
        }).then(function() {
          var $ = m && m.iceRestart;
          if (q.iceGatheringState === "complete" && !$ || q.iceGatheringState === "gathering" && L._iceReady) {
            L._rtcReady = !0;
            var z = {
              originator: "local",
              type: u,
              sdp: q.localDescription.sdp
            };
            return d.debug('emit "sdp"'), L.emit("sdp", z), Promise.resolve(z.sdp);
          }
          return new Promise(function(ee) {
            var Z = !1, re, se;
            L._iceReady = !1;
            var ne = function() {
              if (!Z) {
                q.removeEventListener("icecandidate", re), q.removeEventListener("icegatheringstatechange", se), Z = !0, L._rtcReady = !0, L._iceReady = !0;
                var pe = {
                  originator: "local",
                  type: u,
                  sdp: q.localDescription.sdp
                };
                d.debug('emit "sdp"'), L.emit("sdp", pe), ee(pe.sdp);
              }
            };
            q.addEventListener("icecandidate", re = function(pe) {
              var Te = pe.candidate;
              Te ? L.emit("icecandidate", {
                candidate: Te,
                ready: ne
              }) : ne();
            }), q.addEventListener("icegatheringstatechange", se = function() {
              q.iceGatheringState === "complete" && ne();
            });
          });
        });
      }
      /**
       * Dialog Management
       */
    }, {
      key: "_createDialog",
      value: function(u, m, L) {
        var q = m === "UAS" ? u.to_tag : u.from_tag, $ = m === "UAS" ? u.from_tag : u.to_tag, z = u.call_id + q + $, ee = this._earlyDialogs[z];
        if (L)
          return ee ? !0 : (ee = new I(this, u, m, I.C.STATUS_EARLY), ee.error ? (d.debug(ee.error), this._failed("remote", u, g.causes.INTERNAL_ERROR), !1) : (this._earlyDialogs[z] = ee, !0));
        if (this._from_tag = u.from_tag, this._to_tag = u.to_tag, ee)
          return ee.update(u, m), this._dialog = ee, delete this._earlyDialogs[z], !0;
        var Z = new I(this, u, m);
        return Z.error ? (d.debug(Z.error), this._failed("remote", u, g.causes.INTERNAL_ERROR), !1) : (this._dialog = Z, !0);
      }
      /**
       * In dialog INVITE Reception
       */
    }, {
      key: "_receiveReinvite",
      value: function(u) {
        var m = this;
        d.debug("receiveReinvite()");
        var L = u.hasHeader("Content-Type") ? u.getHeader("Content-Type").toLowerCase() : void 0, q = {
          request: u,
          callback: void 0,
          reject: z.bind(this)
        }, $ = !1;
        function z() {
          var Z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
          $ = !0;
          var re = Z.status_code || 403, se = Z.reason_phrase || "", ne = T.cloneArray(Z.extraHeaders);
          if (this._status !== _.STATUS_CONFIRMED)
            return !1;
          if (re < 300 || re >= 700)
            throw new TypeError("Invalid status_code: ".concat(re));
          u.reply(re, se, ne);
        }
        if (this.emit("reinvite", q), $)
          return;
        if (this._late_sdp = !1, !u.body) {
          this._late_sdp = !0, this._remoteHold && (this._remoteHold = !1, this._onunhold("remote")), this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
            return m._createLocalDescription("offer", m._rtcOfferConstraints);
          }).then(function(Z) {
            ee.call(m, Z);
          }).catch(function() {
            u.reply(500);
          });
          return;
        }
        if (L !== "application/sdp") {
          d.debug("invalid Content-Type"), u.reply(415);
          return;
        }
        this._processInDialogSdpOffer(u).then(function(Z) {
          m._status !== _.STATUS_TERMINATED && ee.call(m, Z);
        }).catch(function(Z) {
          d.warn(Z);
        });
        function ee(Z) {
          var re = this, se = ["Contact: ".concat(this._contact)];
          this._handleSessionTimersInIncomingRequest(u, se), this._late_sdp && (Z = this._mangleOffer(Z)), u.reply(200, null, se, Z, function() {
            re._status = _.STATUS_WAITING_FOR_ACK, re._setInvite2xxTimer(u, Z), re._setACKTimer();
          }), typeof q.callback == "function" && q.callback();
        }
      }
      /**
       * In dialog UPDATE Reception
       */
    }, {
      key: "_receiveUpdate",
      value: function(u) {
        var m = this;
        d.debug("receiveUpdate()");
        var L = u.hasHeader("Content-Type") ? u.getHeader("Content-Type").toLowerCase() : void 0, q = {
          request: u,
          callback: void 0,
          reject: z.bind(this)
        }, $ = !1;
        function z() {
          var Z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
          $ = !0;
          var re = Z.status_code || 403, se = Z.reason_phrase || "", ne = T.cloneArray(Z.extraHeaders);
          if (this._status !== _.STATUS_CONFIRMED)
            return !1;
          if (re < 300 || re >= 700)
            throw new TypeError("Invalid status_code: ".concat(re));
          u.reply(re, se, ne);
        }
        if (this.emit("update", q), $)
          return;
        if (!u.body) {
          ee.call(this, null);
          return;
        }
        if (L !== "application/sdp") {
          d.debug("invalid Content-Type"), u.reply(415);
          return;
        }
        this._processInDialogSdpOffer(u).then(function(Z) {
          m._status !== _.STATUS_TERMINATED && ee.call(m, Z);
        }).catch(function(Z) {
          d.warn(Z);
        });
        function ee(Z) {
          var re = ["Contact: ".concat(this._contact)];
          this._handleSessionTimersInIncomingRequest(u, re), u.reply(200, null, re, Z), typeof q.callback == "function" && q.callback();
        }
      }
    }, {
      key: "_processInDialogSdpOffer",
      value: function(u) {
        var m = this;
        d.debug("_processInDialogSdpOffer()");
        var L = u.parseSDP(), q = !1, $ = y(L.media), z;
        try {
          for ($.s(); !(z = $.n()).done; ) {
            var ee = z.value;
            if (R.indexOf(ee.type) !== -1) {
              var Z = ee.direction || L.direction || "sendrecv";
              if (Z === "sendonly" || Z === "inactive")
                q = !0;
              else {
                q = !1;
                break;
              }
            }
          }
        } catch (ne) {
          $.e(ne);
        } finally {
          $.f();
        }
        var re = {
          originator: "remote",
          type: "offer",
          sdp: u.body
        };
        d.debug('emit "sdp"'), this.emit("sdp", re);
        var se = new RTCSessionDescription({
          type: "offer",
          sdp: re.sdp
        });
        return this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
          if (m._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          return m._connection.setRemoteDescription(se).catch(function(ne) {
            throw u.reply(488), d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', ne), m.emit("peerconnection:setremotedescriptionfailed", ne), ne;
          });
        }).then(function() {
          if (m._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          m._remoteHold === !0 && q === !1 ? (m._remoteHold = !1, m._onunhold("remote")) : m._remoteHold === !1 && q === !0 && (m._remoteHold = !0, m._onhold("remote"));
        }).then(function() {
          if (m._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          return m._createLocalDescription("answer", m._rtcAnswerConstraints).catch(function(ne) {
            throw u.reply(500), d.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]', ne), ne;
          });
        }).catch(function(ne) {
          d.warn("_processInDialogSdpOffer() failed [error: %o]", ne);
        }), this._connectionPromiseQueue;
      }
      /**
       * In dialog Refer Reception
       */
    }, {
      key: "_receiveRefer",
      value: function(u) {
        var m = this;
        if (d.debug("receiveRefer()"), !u.refer_to) {
          d.debug("no Refer-To header field present in REFER"), u.reply(400);
          return;
        }
        if (u.refer_to.uri.scheme !== g.SIP) {
          d.debug("Refer-To header field points to a non-SIP URI scheme"), u.reply(416);
          return;
        }
        u.reply(202);
        var L = new Y(this, u.cseq);
        d.debug('emit "refer"'), this.emit("refer", {
          request: u,
          accept: function(ee, Z) {
            q.call(m, ee, Z);
          },
          reject: function() {
            $.call(m);
          }
        });
        function q(z) {
          var ee = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
          if (z = typeof z == "function" ? z : null, this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_CONFIRMED)
            return !1;
          var Z = new V(this._ua);
          if (Z.on("progress", function(se) {
            var ne = se.response;
            L.notify(ne.status_code, ne.reason_phrase);
          }), Z.on("accepted", function(se) {
            var ne = se.response;
            L.notify(ne.status_code, ne.reason_phrase);
          }), Z.on("_failed", function(se) {
            var ne = se.message, he = se.cause;
            ne ? L.notify(ne.status_code, ne.reason_phrase) : L.notify(487, he);
          }), u.refer_to.uri.hasHeader("replaces")) {
            var re = decodeURIComponent(u.refer_to.uri.getHeader("replaces"));
            ee.extraHeaders = T.cloneArray(ee.extraHeaders), ee.extraHeaders.push("Replaces: ".concat(re));
          }
          Z.connect(u.refer_to.uri.toAor(), ee, z);
        }
        function $() {
          L.notify(603);
        }
      }
      /**
       * In dialog Notify Reception
       */
    }, {
      key: "_receiveNotify",
      value: function(u) {
        switch (d.debug("receiveNotify()"), u.event || u.reply(400), u.event.event) {
          case "refer": {
            var m, L;
            if (u.event.params && u.event.params.id)
              m = u.event.params.id, L = this._referSubscribers[m];
            else if (Object.keys(this._referSubscribers).length === 1)
              L = this._referSubscribers[Object.keys(this._referSubscribers)[0]];
            else {
              u.reply(400, "Missing event id parameter");
              return;
            }
            if (!L) {
              u.reply(481, "Subscription does not exist");
              return;
            }
            L.receiveNotify(u), u.reply(200);
            break;
          }
          default:
            u.reply(489);
        }
      }
      /**
       * INVITE with Replaces Reception
       */
    }, {
      key: "_receiveReplaces",
      value: function(u) {
        var m = this;
        d.debug("receiveReplaces()");
        function L($) {
          var z = this;
          if (this._status !== _.STATUS_WAITING_FOR_ACK && this._status !== _.STATUS_CONFIRMED)
            return !1;
          var ee = new V(this._ua);
          ee.on("confirmed", function() {
            z.terminate();
          }), ee.init_incoming(u, $);
        }
        function q() {
          d.debug("Replaced INVITE rejected by the user"), u.reply(486);
        }
        this.emit("replaces", {
          request: u,
          accept: function(z) {
            L.call(m, z);
          },
          reject: function() {
            q.call(m);
          }
        });
      }
      /**
       * Initial Request Sender
       */
    }, {
      key: "_sendInitialRequest",
      value: function(u, m, L) {
        var q = this, $ = new C(this._ua, this._request, {
          onRequestTimeout: function() {
            q.onRequestTimeout();
          },
          onTransportError: function() {
            q.onTransportError();
          },
          // Update the request on authentication.
          onAuthenticated: function(ee) {
            q._request = ee;
          },
          onReceiveResponse: function(ee) {
            q._receiveInviteResponse(ee);
          }
        });
        Promise.resolve().then(function() {
          if (L)
            return L;
          if (u.audio || u.video)
            return q._localMediaStreamLocallyGenerated = !0, navigator.mediaDevices.getUserMedia(u).catch(function(z) {
              throw q._status === _.STATUS_TERMINATED ? new Error("terminated") : (q._failed("local", null, g.causes.USER_DENIED_MEDIA_ACCESS), d.warn('emit "getusermediafailed" [error:%o]', z), q.emit("getusermediafailed", z), z);
            });
        }).then(function(z) {
          if (q._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          return q._localMediaStream = z, z && z.getTracks().forEach(function(ee) {
            q._connection.addTrack(ee, z);
          }), q._connecting(q._request), q._createLocalDescription("offer", m).catch(function(ee) {
            throw q._failed("local", null, g.causes.WEBRTC_ERROR), ee;
          });
        }).then(function(z) {
          if (q._is_canceled || q._status === _.STATUS_TERMINATED)
            throw new Error("terminated");
          q._request.body = z, q._status = _.STATUS_INVITE_SENT, d.debug('emit "sending" [request:%o]', q._request), q.emit("sending", {
            request: q._request
          }), $.send();
        }).catch(function(z) {
          q._status !== _.STATUS_TERMINATED && d.warn(z);
        });
      }
      /**
       * Get DTMF RTCRtpSender.
       */
    }, {
      key: "_getDTMFRTPSender",
      value: function() {
        var u = this._connection.getSenders().find(function(m) {
          return m.track && m.track.kind === "audio";
        });
        if (!(u && u.dtmf)) {
          d.warn("sendDTMF() | no local audio track to send DTMF with");
          return;
        }
        return u.dtmf;
      }
      /**
       * Reception of Response for Initial INVITE
       */
    }, {
      key: "_receiveInviteResponse",
      value: function(u) {
        var m = this;
        if (d.debug("receiveInviteResponse()"), this._dialog && u.status_code >= 200 && u.status_code <= 299)
          if (this._dialog.id.call_id === u.call_id && this._dialog.id.local_tag === u.from_tag && this._dialog.id.remote_tag === u.to_tag) {
            this.sendRequest(g.ACK);
            return;
          } else {
            var L = new I(this, u, "UAC");
            if (L.error !== void 0) {
              d.debug(L.error);
              return;
            }
            this.sendRequest(g.ACK), this.sendRequest(g.BYE);
            return;
          }
        if (this._is_canceled) {
          u.status_code >= 100 && u.status_code < 200 ? this._request.cancel(this._cancel_reason) : u.status_code >= 200 && u.status_code < 299 && this._acceptAndTerminate(u);
          return;
        }
        if (!(this._status !== _.STATUS_INVITE_SENT && this._status !== _.STATUS_1XX_RECEIVED))
          switch (!0) {
            case /^100$/.test(u.status_code):
              this._status = _.STATUS_1XX_RECEIVED;
              break;
            case /^1[0-9]{2}$/.test(u.status_code): {
              if (!u.to_tag) {
                d.debug("1xx response received without to tag");
                break;
              }
              if (u.hasHeader("contact") && !this._createDialog(u, "UAC", !0))
                break;
              if (this._status = _.STATUS_1XX_RECEIVED, !u.body) {
                this._progress("remote", u);
                break;
              }
              var q = {
                originator: "remote",
                type: "answer",
                sdp: u.body
              };
              d.debug('emit "sdp"'), this.emit("sdp", q);
              var $ = new RTCSessionDescription({
                type: "answer",
                sdp: q.sdp
              });
              this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
                return m._connection.setRemoteDescription($);
              }).then(function() {
                return m._progress("remote", u);
              }).catch(function(re) {
                d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', re), m.emit("peerconnection:setremotedescriptionfailed", re);
              });
              break;
            }
            case /^2[0-9]{2}$/.test(u.status_code): {
              if (this._status = _.STATUS_CONFIRMED, !u.body) {
                this._acceptAndTerminate(u, 400, g.causes.MISSING_SDP), this._failed("remote", u, g.causes.BAD_MEDIA_DESCRIPTION);
                break;
              }
              if (!this._createDialog(u, "UAC"))
                break;
              var z = {
                originator: "remote",
                type: "answer",
                sdp: u.body
              };
              d.debug('emit "sdp"'), this.emit("sdp", z);
              var ee = new RTCSessionDescription({
                type: "answer",
                sdp: z.sdp
              });
              this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
                if (m._connection.signalingState === "stable")
                  return m._connection.createOffer(m._rtcOfferConstraints).then(function(re) {
                    return m._connection.setLocalDescription(re);
                  }).catch(function(re) {
                    m._acceptAndTerminate(u, 500, re.toString()), m._failed("local", u, g.causes.WEBRTC_ERROR);
                  });
              }).then(function() {
                m._connection.setRemoteDescription(ee).then(function() {
                  m._handleSessionTimersInIncomingResponse(u), m._accepted("remote", u), m.sendRequest(g.ACK), m._confirmed("local", null);
                }).catch(function(re) {
                  m._acceptAndTerminate(u, 488, "Not Acceptable Here"), m._failed("remote", u, g.causes.BAD_MEDIA_DESCRIPTION), d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', re), m.emit("peerconnection:setremotedescriptionfailed", re);
                });
              });
              break;
            }
            default: {
              var Z = T.sipErrorCause(u.status_code);
              this._failed("remote", u, Z);
            }
          }
      }
      /**
       * Send Re-INVITE
       */
    }, {
      key: "_sendReinvite",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
        d.debug("sendReinvite()");
        var L = T.cloneArray(m.extraHeaders), q = T.cloneObject(m.eventHandlers), $ = m.rtcOfferConstraints || this._rtcOfferConstraints || null, z = !1;
        L.push("Contact: ".concat(this._contact)), L.push("Content-Type: application/sdp"), this._sessionTimers.running && L.push("Session-Expires: ".concat(this._sessionTimers.currentExpires, ";refresher=").concat(this._sessionTimers.refresher ? "uac" : "uas")), this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
          return u._createLocalDescription("offer", $);
        }).then(function(re) {
          re = u._mangleOffer(re);
          var se = {
            originator: "local",
            type: "offer",
            sdp: re
          };
          d.debug('emit "sdp"'), u.emit("sdp", se), u.sendRequest(g.INVITE, {
            extraHeaders: L,
            body: re,
            eventHandlers: {
              onSuccessResponse: function(he) {
                ee.call(u, he), z = !0;
              },
              onErrorResponse: function(he) {
                Z.call(u, he);
              },
              onTransportError: function() {
                u.onTransportError();
              },
              onRequestTimeout: function() {
                u.onRequestTimeout();
              },
              onDialogError: function() {
                u.onDialogError();
              }
            }
          });
        }).catch(function() {
          Z();
        });
        function ee(re) {
          var se = this;
          if (this._status !== _.STATUS_TERMINATED && (this.sendRequest(g.ACK), !z)) {
            if (this._handleSessionTimersInIncomingResponse(re), re.body) {
              if (!re.hasHeader("Content-Type") || re.getHeader("Content-Type").toLowerCase() !== "application/sdp") {
                Z.call(this);
                return;
              }
            } else {
              Z.call(this);
              return;
            }
            var ne = {
              originator: "remote",
              type: "answer",
              sdp: re.body
            };
            d.debug('emit "sdp"'), this.emit("sdp", ne);
            var he = new RTCSessionDescription({
              type: "answer",
              sdp: ne.sdp
            });
            this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
              return se._connection.setRemoteDescription(he);
            }).then(function() {
              q.succeeded && q.succeeded(re);
            }).catch(function(pe) {
              Z.call(se), d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', pe), se.emit("peerconnection:setremotedescriptionfailed", pe);
            });
          }
        }
        function Z(re) {
          q.failed && q.failed(re);
        }
      }
      /**
       * Send UPDATE
       */
    }, {
      key: "_sendUpdate",
      value: function() {
        var u = this, m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
        d.debug("sendUpdate()");
        var L = T.cloneArray(m.extraHeaders), q = T.cloneObject(m.eventHandlers), $ = m.rtcOfferConstraints || this._rtcOfferConstraints || null, z = m.sdpOffer || !1, ee = !1;
        L.push("Contact: ".concat(this._contact)), this._sessionTimers.running && L.push("Session-Expires: ".concat(this._sessionTimers.currentExpires, ";refresher=").concat(this._sessionTimers.refresher ? "uac" : "uas")), z ? (L.push("Content-Type: application/sdp"), this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
          return u._createLocalDescription("offer", $);
        }).then(function(se) {
          se = u._mangleOffer(se);
          var ne = {
            originator: "local",
            type: "offer",
            sdp: se
          };
          d.debug('emit "sdp"'), u.emit("sdp", ne), u.sendRequest(g.UPDATE, {
            extraHeaders: L,
            body: se,
            eventHandlers: {
              onSuccessResponse: function(pe) {
                Z.call(u, pe), ee = !0;
              },
              onErrorResponse: function(pe) {
                re.call(u, pe);
              },
              onTransportError: function() {
                u.onTransportError();
              },
              onRequestTimeout: function() {
                u.onRequestTimeout();
              },
              onDialogError: function() {
                u.onDialogError();
              }
            }
          });
        }).catch(function() {
          re.call(u);
        })) : this.sendRequest(g.UPDATE, {
          extraHeaders: L,
          eventHandlers: {
            onSuccessResponse: function(ne) {
              Z.call(u, ne);
            },
            onErrorResponse: function(ne) {
              re.call(u, ne);
            },
            onTransportError: function() {
              u.onTransportError();
            },
            onRequestTimeout: function() {
              u.onRequestTimeout();
            },
            onDialogError: function() {
              u.onDialogError();
            }
          }
        });
        function Z(se) {
          var ne = this;
          if (this._status !== _.STATUS_TERMINATED && !ee)
            if (this._handleSessionTimersInIncomingResponse(se), z) {
              if (se.body) {
                if (!se.hasHeader("Content-Type") || se.getHeader("Content-Type").toLowerCase() !== "application/sdp") {
                  re.call(this);
                  return;
                }
              } else {
                re.call(this);
                return;
              }
              var he = {
                originator: "remote",
                type: "answer",
                sdp: se.body
              };
              d.debug('emit "sdp"'), this.emit("sdp", he);
              var pe = new RTCSessionDescription({
                type: "answer",
                sdp: he.sdp
              });
              this._connectionPromiseQueue = this._connectionPromiseQueue.then(function() {
                return ne._connection.setRemoteDescription(pe);
              }).then(function() {
                q.succeeded && q.succeeded(se);
              }).catch(function(Te) {
                re.call(ne), d.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]', Te), ne.emit("peerconnection:setremotedescriptionfailed", Te);
              });
            } else q.succeeded && q.succeeded(se);
        }
        function re(se) {
          q.failed && q.failed(se);
        }
      }
    }, {
      key: "_acceptAndTerminate",
      value: function(u, m, L) {
        d.debug("acceptAndTerminate()");
        var q = [];
        m && (L = L || g.REASON_PHRASE[m] || "", q.push("Reason: SIP ;cause=".concat(m, '; text="').concat(L, '"'))), (this._dialog || this._createDialog(u, "UAC")) && (this.sendRequest(g.ACK), this.sendRequest(g.BYE, {
          extraHeaders: q
        })), this._status = _.STATUS_TERMINATED;
      }
      /**
       * Correctly set the SDP direction attributes if the call is on local hold
       */
    }, {
      key: "_mangleOffer",
      value: function(u) {
        if (!this._localHold && !this._remoteHold)
          return u;
        if (u = j.parse(u), this._localHold && !this._remoteHold) {
          d.debug("mangleOffer() | me on hold, mangling offer");
          var m = y(u.media), L;
          try {
            for (m.s(); !(L = m.n()).done; ) {
              var q = L.value;
              R.indexOf(q.type) !== -1 && (q.direction ? q.direction === "sendrecv" ? q.direction = "sendonly" : q.direction === "recvonly" && (q.direction = "inactive") : q.direction = "sendonly");
            }
          } catch (ne) {
            m.e(ne);
          } finally {
            m.f();
          }
        } else if (this._localHold && this._remoteHold) {
          d.debug("mangleOffer() | both on hold, mangling offer");
          var $ = y(u.media), z;
          try {
            for ($.s(); !(z = $.n()).done; ) {
              var ee = z.value;
              R.indexOf(ee.type) !== -1 && (ee.direction = "inactive");
            }
          } catch (ne) {
            $.e(ne);
          } finally {
            $.f();
          }
        } else if (this._remoteHold) {
          d.debug("mangleOffer() | remote on hold, mangling offer");
          var Z = y(u.media), re;
          try {
            for (Z.s(); !(re = Z.n()).done; ) {
              var se = re.value;
              R.indexOf(se.type) !== -1 && (se.direction ? se.direction === "sendrecv" ? se.direction = "recvonly" : se.direction === "recvonly" && (se.direction = "inactive") : se.direction = "recvonly");
            }
          } catch (ne) {
            Z.e(ne);
          } finally {
            Z.f();
          }
        }
        return j.write(u);
      }
    }, {
      key: "_setLocalMediaStatus",
      value: function() {
        var u = !0, m = !0;
        (this._localHold || this._remoteHold) && (u = !1, m = !1), this._audioMuted && (u = !1), this._videoMuted && (m = !1), this._toggleMuteAudio(!u), this._toggleMuteVideo(!m);
      }
      /**
       * Handle SessionTimers for an incoming INVITE or UPDATE.
       * @param  {IncomingRequest} request
       * @param  {Array} responseExtraHeaders  Extra headers for the 200 response.
       */
    }, {
      key: "_handleSessionTimersInIncomingRequest",
      value: function(u, m) {
        if (this._sessionTimers.enabled) {
          var L;
          u.session_expires && u.session_expires >= g.MIN_SESSION_EXPIRES ? (this._sessionTimers.currentExpires = u.session_expires, L = u.session_expires_refresher || "uas") : (this._sessionTimers.currentExpires = this._sessionTimers.defaultExpires, L = "uas"), m.push("Session-Expires: ".concat(this._sessionTimers.currentExpires, ";refresher=").concat(L)), this._sessionTimers.refresher = L === "uas", this._runSessionTimer();
        }
      }
      /**
       * Handle SessionTimers for an incoming response to INVITE or UPDATE.
       * @param  {IncomingResponse} response
       */
    }, {
      key: "_handleSessionTimersInIncomingResponse",
      value: function(u) {
        if (this._sessionTimers.enabled) {
          var m;
          u.session_expires && u.session_expires >= g.MIN_SESSION_EXPIRES ? (this._sessionTimers.currentExpires = u.session_expires, m = u.session_expires_refresher || "uac") : (this._sessionTimers.currentExpires = this._sessionTimers.defaultExpires, m = "uac"), this._sessionTimers.refresher = m === "uac", this._runSessionTimer();
        }
      }
    }, {
      key: "_runSessionTimer",
      value: function() {
        var u = this, m = this._sessionTimers.currentExpires;
        this._sessionTimers.running = !0, clearTimeout(this._sessionTimers.timer), this._sessionTimers.refresher ? this._sessionTimers.timer = setTimeout(function() {
          u._status !== _.STATUS_TERMINATED && u._isReadyToReOffer() && (d.debug("runSessionTimer() | sending session refresh request"), u._sessionTimers.refreshMethod === g.UPDATE ? u._sendUpdate() : u._sendReinvite());
        }, m * 500) : this._sessionTimers.timer = setTimeout(function() {
          u._status !== _.STATUS_TERMINATED && (d.warn("runSessionTimer() | timer expired, terminating the session"), u.terminate({
            cause: g.causes.REQUEST_TIMEOUT,
            status_code: 408,
            reason_phrase: "Session Timer Expired"
          }));
        }, m * 1100);
      }
    }, {
      key: "_toggleMuteAudio",
      value: function(u) {
        var m = this._connection.getSenders().filter(function(z) {
          return z.track && z.track.kind === "audio";
        }), L = y(m), q;
        try {
          for (L.s(); !(q = L.n()).done; ) {
            var $ = q.value;
            $.track.enabled = !u;
          }
        } catch (z) {
          L.e(z);
        } finally {
          L.f();
        }
      }
    }, {
      key: "_toggleMuteVideo",
      value: function(u) {
        var m = this._connection.getSenders().filter(function(z) {
          return z.track && z.track.kind === "video";
        }), L = y(m), q;
        try {
          for (L.s(); !(q = L.n()).done; ) {
            var $ = q.value;
            $.track.enabled = !u;
          }
        } catch (z) {
          L.e(z);
        } finally {
          L.f();
        }
      }
    }, {
      key: "_newRTCSession",
      value: function(u, m) {
        d.debug("newRTCSession()"), this._ua.newRTCSession(this, {
          originator: u,
          session: this,
          request: m
        });
      }
    }, {
      key: "_connecting",
      value: function(u) {
        d.debug("session connecting"), d.debug('emit "connecting"'), this.emit("connecting", {
          request: u
        });
      }
    }, {
      key: "_progress",
      value: function(u, m) {
        d.debug("session progress"), d.debug('emit "progress"'), this.emit("progress", {
          originator: u,
          response: m || null
        });
      }
    }, {
      key: "_accepted",
      value: function(u, m) {
        d.debug("session accepted"), this._start_time = /* @__PURE__ */ new Date(), d.debug('emit "accepted"'), this.emit("accepted", {
          originator: u,
          response: m || null
        });
      }
    }, {
      key: "_confirmed",
      value: function(u, m) {
        d.debug("session confirmed"), this._is_confirmed = !0, d.debug('emit "confirmed"'), this.emit("confirmed", {
          originator: u,
          ack: m || null
        });
      }
    }, {
      key: "_ended",
      value: function(u, m, L) {
        d.debug("session ended"), this._end_time = /* @__PURE__ */ new Date(), this._close(), d.debug('emit "ended"'), this.emit("ended", {
          originator: u,
          message: m || null,
          cause: L
        });
      }
    }, {
      key: "_failed",
      value: function(u, m, L) {
        d.debug("session failed"), d.debug('emit "_failed"'), this.emit("_failed", {
          originator: u,
          message: m || null,
          cause: L
        }), this._close(), d.debug('emit "failed"'), this.emit("failed", {
          originator: u,
          message: m || null,
          cause: L
        });
      }
    }, {
      key: "_onhold",
      value: function(u) {
        d.debug("session onhold"), this._setLocalMediaStatus(), d.debug('emit "hold"'), this.emit("hold", {
          originator: u
        });
      }
    }, {
      key: "_onunhold",
      value: function(u) {
        d.debug("session onunhold"), this._setLocalMediaStatus(), d.debug('emit "unhold"'), this.emit("unhold", {
          originator: u
        });
      }
    }, {
      key: "_onmute",
      value: function(u) {
        var m = u.audio, L = u.video;
        d.debug("session onmute"), this._setLocalMediaStatus(), d.debug('emit "muted"'), this.emit("muted", {
          audio: m,
          video: L
        });
      }
    }, {
      key: "_onunmute",
      value: function(u) {
        var m = u.audio, L = u.video;
        d.debug("session onunmute"), this._setLocalMediaStatus(), d.debug('emit "unmuted"'), this.emit("unmuted", {
          audio: m,
          video: L
        });
      }
    }, {
      key: "C",
      get: function() {
        return _;
      }
      // Expose session failed/ended causes as a property of the RTCSession instance.
    }, {
      key: "causes",
      get: function() {
        return g.causes;
      }
    }, {
      key: "id",
      get: function() {
        return this._id;
      }
    }, {
      key: "connection",
      get: function() {
        return this._connection;
      }
    }, {
      key: "contact",
      get: function() {
        return this._contact;
      }
    }, {
      key: "direction",
      get: function() {
        return this._direction;
      }
    }, {
      key: "local_identity",
      get: function() {
        return this._local_identity;
      }
    }, {
      key: "remote_identity",
      get: function() {
        return this._remote_identity;
      }
    }, {
      key: "start_time",
      get: function() {
        return this._start_time;
      }
    }, {
      key: "end_time",
      get: function() {
        return this._end_time;
      }
    }, {
      key: "data",
      get: function() {
        return this._data;
      },
      set: function(u) {
        this._data = u;
      }
    }, {
      key: "status",
      get: function() {
        return this._status;
      }
    }]), V;
  }(W), Rn;
}
var wn, ii;
function Nl() {
  if (ii) return wn;
  ii = 1;
  function U(T) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(w) {
      return typeof w;
    } : U = function(w) {
      return w && typeof Symbol == "function" && w.constructor === Symbol && w !== Symbol.prototype ? "symbol" : typeof w;
    }, U(T);
  }
  function y(T, v) {
    if (!(T instanceof v))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(T, v) {
    for (var w = 0; w < v.length; w++) {
      var I = v[w];
      I.enumerable = I.enumerable || !1, I.configurable = !0, "value" in I && (I.writable = !0), Object.defineProperty(T, I.key, I);
    }
  }
  function l(T, v, w) {
    return v && M(T.prototype, v), T;
  }
  function X(T, v) {
    if (typeof v != "function" && v !== null)
      throw new TypeError("Super expression must either be null or a function");
    T.prototype = Object.create(v && v.prototype, { constructor: { value: T, writable: !0, configurable: !0 } }), v && F(T, v);
  }
  function F(T, v) {
    return F = Object.setPrototypeOf || function(I, C) {
      return I.__proto__ = C, I;
    }, F(T, v);
  }
  function t(T) {
    var v = i();
    return function() {
      var I = c(T), C;
      if (v) {
        var O = c(this).constructor;
        C = Reflect.construct(I, arguments, O);
      } else
        C = I.apply(this, arguments);
      return b(this, C);
    };
  }
  function b(T, v) {
    return v && (U(v) === "object" || typeof v == "function") ? v : E(T);
  }
  function E(T) {
    if (T === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return T;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(T) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(w) {
      return w.__proto__ || Object.getPrototypeOf(w);
    }, c(T);
  }
  var o = Be().EventEmitter, h = Ie(), p = Re(), W = He(), j = Oe(), P = ht(), g = Ge(), k = Ve(), N = new h("Message");
  return wn = /* @__PURE__ */ function(T) {
    X(w, T);
    var v = t(w);
    function w(I) {
      var C;
      return y(this, w), C = v.call(this), C._ua = I, C._request = null, C._closed = !1, C._direction = null, C._local_identity = null, C._remote_identity = null, C._is_replied = !1, C._data = {}, C;
    }
    return l(w, [{
      key: "send",
      value: function(C, O) {
        var K = this, Y = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, D = C;
        if (C === void 0 || O === void 0)
          throw new TypeError("Not enough arguments");
        if (C = this._ua.normalizeTarget(C), !C)
          throw new TypeError("Invalid target: ".concat(D));
        var B = j.cloneArray(Y.extraHeaders), d = j.cloneObject(Y.eventHandlers), _ = Y.contentType || "text/plain", R = {};
        Y.fromUserName && (R.from_uri = new k("sip", Y.fromUserName, this._ua.configuration.uri.host), B.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))), Y.fromDisplayName && (R.from_display_name = Y.fromDisplayName);
        for (var A in d)
          Object.prototype.hasOwnProperty.call(d, A) && this.on(A, d[A]);
        B.push("Content-Type: ".concat(_)), this._request = new W.OutgoingRequest(p.MESSAGE, C, this._ua, R, B), O && (this._request.body = O);
        var G = new P(this._ua, this._request, {
          onRequestTimeout: function() {
            K._onRequestTimeout();
          },
          onTransportError: function() {
            K._onTransportError();
          },
          onReceiveResponse: function(x) {
            K._receiveResponse(x);
          }
        });
        this._newMessage("local", this._request), G.send();
      }
    }, {
      key: "init_incoming",
      value: function(C) {
        this._request = C, this._newMessage("remote", C), this._is_replied || (this._is_replied = !0, C.reply(200)), this._close();
      }
      /**
       * Accept the incoming Message
       * Only valid for incoming Messages
       */
    }, {
      key: "accept",
      value: function() {
        var C = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, O = j.cloneArray(C.extraHeaders), K = C.body;
        if (this._direction !== "incoming")
          throw new g.NotSupportedError('"accept" not supported for outgoing Message');
        if (this._is_replied)
          throw new Error("incoming Message already replied");
        this._is_replied = !0, this._request.reply(200, null, O, K);
      }
      /**
       * Reject the incoming Message
       * Only valid for incoming Messages
       */
    }, {
      key: "reject",
      value: function() {
        var C = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, O = C.status_code || 480, K = C.reason_phrase, Y = j.cloneArray(C.extraHeaders), D = C.body;
        if (this._direction !== "incoming")
          throw new g.NotSupportedError('"reject" not supported for outgoing Message');
        if (this._is_replied)
          throw new Error("incoming Message already replied");
        if (O < 300 || O >= 700)
          throw new TypeError("Invalid status_code: ".concat(O));
        this._is_replied = !0, this._request.reply(O, K, Y, D);
      }
    }, {
      key: "_receiveResponse",
      value: function(C) {
        if (!this._closed)
          switch (!0) {
            case /^1[0-9]{2}$/.test(C.status_code):
              break;
            case /^2[0-9]{2}$/.test(C.status_code):
              this._succeeded("remote", C);
              break;
            default: {
              var O = j.sipErrorCause(C.status_code);
              this._failed("remote", C, O);
              break;
            }
          }
      }
    }, {
      key: "_onRequestTimeout",
      value: function() {
        this._closed || this._failed("system", null, p.causes.REQUEST_TIMEOUT);
      }
    }, {
      key: "_onTransportError",
      value: function() {
        this._closed || this._failed("system", null, p.causes.CONNECTION_ERROR);
      }
    }, {
      key: "_close",
      value: function() {
        this._closed = !0, this._ua.destroyMessage(this);
      }
      /**
       * Internal Callbacks
       */
    }, {
      key: "_newMessage",
      value: function(C, O) {
        C === "remote" ? (this._direction = "incoming", this._local_identity = O.to, this._remote_identity = O.from) : C === "local" && (this._direction = "outgoing", this._local_identity = O.from, this._remote_identity = O.to), this._ua.newMessage(this, {
          originator: C,
          message: this,
          request: O
        });
      }
    }, {
      key: "_failed",
      value: function(C, O, K) {
        N.debug("MESSAGE failed"), this._close(), N.debug('emit "failed"'), this.emit("failed", {
          originator: C,
          response: O || null,
          cause: K
        });
      }
    }, {
      key: "_succeeded",
      value: function(C, O) {
        N.debug("MESSAGE succeeded"), this._close(), N.debug('emit "succeeded"'), this.emit("succeeded", {
          originator: C,
          response: O
        });
      }
    }, {
      key: "direction",
      get: function() {
        return this._direction;
      }
    }, {
      key: "local_identity",
      get: function() {
        return this._local_identity;
      }
    }, {
      key: "remote_identity",
      get: function() {
        return this._remote_identity;
      }
    }]), w;
  }(o), wn;
}
var In, li;
function kl() {
  if (li) return In;
  li = 1;
  function U(N) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(v) {
      return typeof v;
    } : U = function(v) {
      return v && typeof Symbol == "function" && v.constructor === Symbol && v !== Symbol.prototype ? "symbol" : typeof v;
    }, U(N);
  }
  function y(N, T) {
    if (!(N instanceof T))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(N, T) {
    for (var v = 0; v < T.length; v++) {
      var w = T[v];
      w.enumerable = w.enumerable || !1, w.configurable = !0, "value" in w && (w.writable = !0), Object.defineProperty(N, w.key, w);
    }
  }
  function l(N, T, v) {
    return T && M(N.prototype, T), N;
  }
  function X(N, T) {
    if (typeof T != "function" && T !== null)
      throw new TypeError("Super expression must either be null or a function");
    N.prototype = Object.create(T && T.prototype, { constructor: { value: N, writable: !0, configurable: !0 } }), T && F(N, T);
  }
  function F(N, T) {
    return F = Object.setPrototypeOf || function(w, I) {
      return w.__proto__ = I, w;
    }, F(N, T);
  }
  function t(N) {
    var T = i();
    return function() {
      var w = c(N), I;
      if (T) {
        var C = c(this).constructor;
        I = Reflect.construct(w, arguments, C);
      } else
        I = w.apply(this, arguments);
      return b(this, I);
    };
  }
  function b(N, T) {
    return T && (U(T) === "object" || typeof T == "function") ? T : E(N);
  }
  function E(N) {
    if (N === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return N;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(N) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(v) {
      return v.__proto__ || Object.getPrototypeOf(v);
    }, c(N);
  }
  var o = Be().EventEmitter, h = Ie(), p = Re(), W = He(), j = Oe(), P = ht(), g = Ge(), k = new h("Options");
  return In = /* @__PURE__ */ function(N) {
    X(v, N);
    var T = t(v);
    function v(w) {
      var I;
      return y(this, v), I = T.call(this), I._ua = w, I._request = null, I._closed = !1, I._direction = null, I._local_identity = null, I._remote_identity = null, I._is_replied = !1, I._data = {}, I;
    }
    return l(v, [{
      key: "send",
      value: function(I, C) {
        var O = this, K = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, Y = I;
        if (I === void 0)
          throw new TypeError("A target is required for OPTIONS");
        if (I = this._ua.normalizeTarget(I), !I)
          throw new TypeError("Invalid target: ".concat(Y));
        var D = j.cloneArray(K.extraHeaders), B = j.cloneObject(K.eventHandlers), d = K.contentType || "application/sdp";
        for (var _ in B)
          Object.prototype.hasOwnProperty.call(B, _) && this.on(_, B[_]);
        D.push("Content-Type: ".concat(d)), this._request = new W.OutgoingRequest(p.OPTIONS, I, this._ua, null, D), C && (this._request.body = C);
        var R = new P(this._ua, this._request, {
          onRequestTimeout: function() {
            O._onRequestTimeout();
          },
          onTransportError: function() {
            O._onTransportError();
          },
          onReceiveResponse: function(G) {
            O._receiveResponse(G);
          }
        });
        this._newOptions("local", this._request), R.send();
      }
    }, {
      key: "init_incoming",
      value: function(I) {
        this._request = I, this._newOptions("remote", I), this._is_replied || (this._is_replied = !0, I.reply(200)), this._close();
      }
      /**
       * Accept the incoming Options
       * Only valid for incoming Options
       */
    }, {
      key: "accept",
      value: function() {
        var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, C = j.cloneArray(I.extraHeaders), O = I.body;
        if (this._direction !== "incoming")
          throw new g.NotSupportedError('"accept" not supported for outgoing Options');
        if (this._is_replied)
          throw new Error("incoming Options already replied");
        this._is_replied = !0, this._request.reply(200, null, C, O);
      }
      /**
       * Reject the incoming Options
       * Only valid for incoming Options
       */
    }, {
      key: "reject",
      value: function() {
        var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, C = I.status_code || 480, O = I.reason_phrase, K = j.cloneArray(I.extraHeaders), Y = I.body;
        if (this._direction !== "incoming")
          throw new g.NotSupportedError('"reject" not supported for outgoing Options');
        if (this._is_replied)
          throw new Error("incoming Options already replied");
        if (C < 300 || C >= 700)
          throw new TypeError("Invalid status_code: ".concat(C));
        this._is_replied = !0, this._request.reply(C, O, K, Y);
      }
    }, {
      key: "_receiveResponse",
      value: function(I) {
        if (!this._closed)
          switch (!0) {
            case /^1[0-9]{2}$/.test(I.status_code):
              break;
            case /^2[0-9]{2}$/.test(I.status_code):
              this._succeeded("remote", I);
              break;
            default: {
              var C = j.sipErrorCause(I.status_code);
              this._failed("remote", I, C);
              break;
            }
          }
      }
    }, {
      key: "_onRequestTimeout",
      value: function() {
        this._closed || this._failed("system", null, p.causes.REQUEST_TIMEOUT);
      }
    }, {
      key: "_onTransportError",
      value: function() {
        this._closed || this._failed("system", null, p.causes.CONNECTION_ERROR);
      }
    }, {
      key: "_close",
      value: function() {
        this._closed = !0, this._ua.destroyMessage(this);
      }
      /**
       * Internal Callbacks
       */
    }, {
      key: "_newOptions",
      value: function(I, C) {
        I === "remote" ? (this._direction = "incoming", this._local_identity = C.to, this._remote_identity = C.from) : I === "local" && (this._direction = "outgoing", this._local_identity = C.from, this._remote_identity = C.to), this._ua.newOptions(this, {
          originator: I,
          message: this,
          request: C
        });
      }
    }, {
      key: "_failed",
      value: function(I, C, O) {
        k.debug("OPTIONS failed"), this._close(), k.debug('emit "failed"'), this.emit("failed", {
          originator: I,
          response: C || null,
          cause: O
        });
      }
    }, {
      key: "_succeeded",
      value: function(I, C) {
        k.debug("OPTIONS succeeded"), this._close(), k.debug('emit "succeeded"'), this.emit("succeeded", {
          originator: I,
          response: C
        });
      }
    }, {
      key: "direction",
      get: function() {
        return this._direction;
      }
    }, {
      key: "local_identity",
      get: function() {
        return this._local_identity;
      }
    }, {
      key: "remote_identity",
      get: function() {
        return this._remote_identity;
      }
    }]), v;
  }(o), In;
}
var On = {}, ai;
function Ti() {
  if (ai) return On;
  ai = 1;
  var U = Ie(), y = Oe(), M = Ue(), l = new U("Socket");
  return On.isSocket = function(X) {
    if (Array.isArray(X))
      return !1;
    if (typeof X > "u")
      return l.warn("undefined JsSIP.Socket instance"), !1;
    try {
      if (!y.isString(X.url))
        throw l.warn("missing or invalid JsSIP.Socket url property"), new Error("Missing or invalid JsSIP.Socket url property");
      if (!y.isString(X.via_transport))
        throw l.warn("missing or invalid JsSIP.Socket via_transport property"), new Error("Missing or invalid JsSIP.Socket via_transport property");
      if (M.parse(X.sip_uri, "SIP_URI") === -1)
        throw l.warn("missing or invalid JsSIP.Socket sip_uri property"), new Error("missing or invalid JsSIP.Socket sip_uri property");
    } catch {
      return !1;
    }
    try {
      ["connect", "disconnect", "send"].forEach(function(F) {
        if (!y.isFunction(X[F]))
          throw l.warn("missing or invalid JsSIP.Socket method: ".concat(F)), new Error("Missing or invalid JsSIP.Socket method: ".concat(F));
      });
    } catch {
      return !1;
    }
    return !0;
  }, On;
}
var Nn, oi;
function Dl() {
  if (oi) return Nn;
  oi = 1;
  function U(E, i) {
    if (!(E instanceof i))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(E, i) {
    for (var c = 0; c < i.length; c++) {
      var o = i[c];
      o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(E, o.key, o);
    }
  }
  function M(E, i, c) {
    return i && y(E.prototype, i), E;
  }
  var l = Ie(), X = Ti(), F = Re(), t = new l("Transport"), b = {
    // Transport status.
    STATUS_CONNECTED: 0,
    STATUS_CONNECTING: 1,
    STATUS_DISCONNECTED: 2,
    // Socket status.
    SOCKET_STATUS_READY: 0,
    SOCKET_STATUS_ERROR: 1,
    // Recovery options.
    recovery_options: {
      // minimum interval in seconds between recover attempts.
      min_interval: F.CONNECTION_RECOVERY_MIN_INTERVAL,
      // maximum interval in seconds between recover attempts.
      max_interval: F.CONNECTION_RECOVERY_MAX_INTERVAL
    }
  };
  return Nn = /* @__PURE__ */ function() {
    function E(i) {
      var c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : b.recovery_options;
      U(this, E), t.debug("new()"), this.status = b.STATUS_DISCONNECTED, this.socket = null, this.sockets = [], this.recovery_options = c, this.recover_attempts = 0, this.recovery_timer = null, this.close_requested = !1;
      try {
        this.textDecoder = new TextDecoder("utf8");
      } catch (o) {
        t.warn("cannot use TextDecoder: ".concat(o));
      }
      if (typeof i > "u")
        throw new TypeError("Invalid argument. undefined 'sockets' argument");
      i instanceof Array || (i = [i]), i.forEach(function(o) {
        if (!X.isSocket(o.socket))
          throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");
        if (o.weight && !Number(o.weight))
          throw new TypeError("Invalid argument. 'weight' attribute is not a number");
        this.sockets.push({
          socket: o.socket,
          weight: o.weight || 0,
          status: b.SOCKET_STATUS_READY
        });
      }, this), this._getSocket();
    }
    return M(E, [{
      key: "connect",
      value: function() {
        if (t.debug("connect()"), this.isConnected()) {
          t.debug("Transport is already connected");
          return;
        } else if (this.isConnecting()) {
          t.debug("Transport is connecting");
          return;
        }
        this.close_requested = !1, this.status = b.STATUS_CONNECTING, this.onconnecting({
          socket: this.socket,
          attempts: this.recover_attempts
        }), this.close_requested || (this.socket.onconnect = this._onConnect.bind(this), this.socket.ondisconnect = this._onDisconnect.bind(this), this.socket.ondata = this._onData.bind(this), this.socket.connect());
      }
    }, {
      key: "disconnect",
      value: function() {
        t.debug("close()"), this.close_requested = !0, this.recover_attempts = 0, this.status = b.STATUS_DISCONNECTED, this.recovery_timer !== null && (clearTimeout(this.recovery_timer), this.recovery_timer = null), this.socket.onconnect = function() {
        }, this.socket.ondisconnect = function() {
        }, this.socket.ondata = function() {
        }, this.socket.disconnect(), this.ondisconnect({
          socket: this.socket,
          error: !1
        });
      }
    }, {
      key: "send",
      value: function(c) {
        if (t.debug("send()"), !this.isConnected())
          return t.warn("unable to send message, transport is not connected"), !1;
        var o = c.toString();
        return t.debug(`sending message:

`.concat(o, `
`)), this.socket.send(o);
      }
    }, {
      key: "isConnected",
      value: function() {
        return this.status === b.STATUS_CONNECTED;
      }
    }, {
      key: "isConnecting",
      value: function() {
        return this.status === b.STATUS_CONNECTING;
      }
      /**
       * Private API.
       */
    }, {
      key: "_reconnect",
      value: function() {
        var c = this;
        this.recover_attempts += 1;
        var o = Math.floor(Math.random() * Math.pow(2, this.recover_attempts) + 1);
        o < this.recovery_options.min_interval ? o = this.recovery_options.min_interval : o > this.recovery_options.max_interval && (o = this.recovery_options.max_interval), t.debug("reconnection attempt: ".concat(this.recover_attempts, ". next connection attempt in ").concat(o, " seconds")), this.recovery_timer = setTimeout(function() {
          !c.close_requested && !(c.isConnected() || c.isConnecting()) && (c._getSocket(), c.connect());
        }, o * 1e3);
      }
      /**
       * get the next available socket with higher weight
       */
    }, {
      key: "_getSocket",
      value: function() {
        var c = [];
        if (this.sockets.forEach(function(h) {
          h.status !== b.SOCKET_STATUS_ERROR && (c.length === 0 ? c.push(h) : h.weight > c[0].weight ? c = [h] : h.weight === c[0].weight && c.push(h));
        }), c.length === 0) {
          this.sockets.forEach(function(h) {
            h.status = b.SOCKET_STATUS_READY;
          }), this._getSocket();
          return;
        }
        var o = Math.floor(Math.random() * c.length);
        this.socket = c[o].socket;
      }
      /**
       * Socket Event Handlers
       */
    }, {
      key: "_onConnect",
      value: function() {
        this.recover_attempts = 0, this.status = b.STATUS_CONNECTED, this.recovery_timer !== null && (clearTimeout(this.recovery_timer), this.recovery_timer = null), this.onconnect({
          socket: this
        });
      }
    }, {
      key: "_onDisconnect",
      value: function(c, o, h) {
        this.status = b.STATUS_DISCONNECTED, this.ondisconnect({
          socket: this.socket,
          error: c,
          code: o,
          reason: h
        }), !this.close_requested && (this.sockets.forEach(function(p) {
          this.socket === p.socket && (p.status = b.SOCKET_STATUS_ERROR);
        }, this), this._reconnect(c));
      }
    }, {
      key: "_onData",
      value: function(c) {
        if (c === `\r
\r
`) {
          t.debug("received message with double-CRLF Keep Alive request");
          try {
            this.socket.send(`\r
`);
          } catch (o) {
            t.warn("error sending Keep Alive response: ".concat(o));
          }
          return;
        }
        if (c === `\r
`) {
          t.debug("received message with CRLF Keep Alive response");
          return;
        } else if (typeof c != "string") {
          try {
            this.textDecoder ? c = this.textDecoder.decode(c) : c = String.fromCharCode.apply(null, new Uint8Array(c));
          } catch {
            t.debug("received binary message failed to be converted into string, message discarded");
            return;
          }
          t.debug(`received binary message:

`.concat(c, `
`));
        } else
          t.debug(`received text message:

`.concat(c, `
`));
        this.ondata({
          transport: this,
          message: c
        });
      }
    }, {
      key: "via_transport",
      get: function() {
        return this.socket.via_transport;
      }
    }, {
      key: "url",
      get: function() {
        return this.socket.url;
      }
    }, {
      key: "sip_uri",
      get: function() {
        return this.socket.sip_uri;
      }
    }]), E;
  }(), Nn;
}
var kn = {}, ui;
function Pl() {
  if (ui) return kn;
  ui = 1;
  function U(i, c) {
    var o;
    if (typeof Symbol > "u" || i[Symbol.iterator] == null) {
      if (Array.isArray(i) || (o = y(i)) || c) {
        o && (i = o);
        var h = 0, p = function() {
        };
        return { s: p, n: function() {
          return h >= i.length ? { done: !0 } : { done: !1, value: i[h++] };
        }, e: function(k) {
          throw k;
        }, f: p };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var W = !0, j = !1, P;
    return { s: function() {
      o = i[Symbol.iterator]();
    }, n: function() {
      var k = o.next();
      return W = k.done, k;
    }, e: function(k) {
      j = !0, P = k;
    }, f: function() {
      try {
        !W && o.return != null && o.return();
      } finally {
        if (j) throw P;
      }
    } };
  }
  function y(i, c) {
    if (i) {
      if (typeof i == "string") return M(i, c);
      var o = Object.prototype.toString.call(i).slice(8, -1);
      if (o === "Object" && i.constructor && (o = i.constructor.name), o === "Map" || o === "Set") return Array.from(i);
      if (o === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)) return M(i, c);
    }
  }
  function M(i, c) {
    (c == null || c > i.length) && (c = i.length);
    for (var o = 0, h = new Array(c); o < c; o++)
      h[o] = i[o];
    return h;
  }
  var l = Ie(), X = Ue(), F = He(), t = new l("Parser");
  kn.parseMessage = function(i, c) {
    var o, h, p = i.indexOf(`\r
`);
    if (p === -1) {
      t.warn("parseMessage() | no CRLF found, not a SIP message");
      return;
    }
    var W = i.substring(0, p), j = X.parse(W, "Request_Response");
    if (j === -1) {
      t.warn('parseMessage() | error parsing first line of SIP message: "'.concat(W, '"'));
      return;
    } else j.status_code ? (o = new F.IncomingResponse(), o.status_code = j.status_code, o.reason_phrase = j.reason_phrase) : (o = new F.IncomingRequest(c), o.method = j.method, o.ruri = j.uri);
    o.data = i;
    for (var P = p + 2; ; ) {
      if (p = b(i, P), p === -2) {
        h = P + 2;
        break;
      } else if (p === -1) {
        t.warn("parseMessage() | malformed message");
        return;
      }
      if (j = E(o, i, P, p), j !== !0) {
        t.warn("parseMessage() |", j.error);
        return;
      }
      P = p + 2;
    }
    if (o.hasHeader("content-length")) {
      var g = o.getHeader("content-length");
      o.body = i.substr(h, g);
    } else
      o.body = i.substring(h);
    return o;
  };
  function b(i, c) {
    var o = c, h = 0, p = 0;
    if (i.substring(o, o + 2).match(/(^\r\n)/))
      return -2;
    for (; h === 0; ) {
      if (p = i.indexOf(`\r
`, o), p === -1)
        return p;
      !i.substring(p + 2, p + 4).match(/(^\r\n)/) && i.charAt(p + 2).match(/(^\s+)/) ? o = p + 2 : h = p;
    }
    return h;
  }
  function E(i, c, o, h) {
    var p, W = c.indexOf(":", o), j = c.substring(o, W).trim(), P = c.substring(W + 1, h).trim();
    switch (j.toLowerCase()) {
      case "via":
      case "v":
        i.addHeader("via", P), i.getHeaders("via").length === 1 ? (p = i.parseHeader("Via"), p && (i.via = p, i.via_branch = p.branch)) : p = 0;
        break;
      case "from":
      case "f":
        i.setHeader("from", P), p = i.parseHeader("from"), p && (i.from = p, i.from_tag = p.getParam("tag"));
        break;
      case "to":
      case "t":
        i.setHeader("to", P), p = i.parseHeader("to"), p && (i.to = p, i.to_tag = p.getParam("tag"));
        break;
      case "record-route":
        if (p = X.parse(P, "Record_Route"), p === -1)
          p = void 0;
        else {
          var g = U(p), k;
          try {
            for (g.s(); !(k = g.n()).done; ) {
              var N = k.value;
              i.addHeader("record-route", P.substring(N.possition, N.offset)), i.headers["Record-Route"][i.getHeaders("record-route").length - 1].parsed = N.parsed;
            }
          } catch (I) {
            g.e(I);
          } finally {
            g.f();
          }
        }
        break;
      case "call-id":
      case "i":
        i.setHeader("call-id", P), p = i.parseHeader("call-id"), p && (i.call_id = P);
        break;
      case "contact":
      case "m":
        if (p = X.parse(P, "Contact"), p === -1)
          p = void 0;
        else {
          var T = U(p), v;
          try {
            for (T.s(); !(v = T.n()).done; ) {
              var w = v.value;
              i.addHeader("contact", P.substring(w.possition, w.offset)), i.headers.Contact[i.getHeaders("contact").length - 1].parsed = w.parsed;
            }
          } catch (I) {
            T.e(I);
          } finally {
            T.f();
          }
        }
        break;
      case "content-length":
      case "l":
        i.setHeader("content-length", P), p = i.parseHeader("content-length");
        break;
      case "content-type":
      case "c":
        i.setHeader("content-type", P), p = i.parseHeader("content-type");
        break;
      case "cseq":
        i.setHeader("cseq", P), p = i.parseHeader("cseq"), p && (i.cseq = p.value), i instanceof F.IncomingResponse && (i.method = p.method);
        break;
      case "max-forwards":
        i.setHeader("max-forwards", P), p = i.parseHeader("max-forwards");
        break;
      case "www-authenticate":
        i.setHeader("www-authenticate", P), p = i.parseHeader("www-authenticate");
        break;
      case "proxy-authenticate":
        i.setHeader("proxy-authenticate", P), p = i.parseHeader("proxy-authenticate");
        break;
      case "session-expires":
      case "x":
        i.setHeader("session-expires", P), p = i.parseHeader("session-expires"), p && (i.session_expires = p.expires, i.session_expires_refresher = p.refresher);
        break;
      case "refer-to":
      case "r":
        i.setHeader("refer-to", P), p = i.parseHeader("refer-to"), p && (i.refer_to = p);
        break;
      case "replaces":
        i.setHeader("replaces", P), p = i.parseHeader("replaces"), p && (i.replaces = p);
        break;
      case "event":
      case "o":
        i.setHeader("event", P), p = i.parseHeader("event"), p && (i.event = p);
        break;
      default:
        i.addHeader(j, P), p = 0;
    }
    return p === void 0 ? {
      error: 'error parsing header "'.concat(j, '"')
    } : !0;
  }
  return kn;
}
var Dn, fi;
function xl() {
  if (fi) return Dn;
  fi = 1;
  function U(w, I) {
    var C;
    if (typeof Symbol > "u" || w[Symbol.iterator] == null) {
      if (Array.isArray(w) || (C = y(w)) || I) {
        C && (w = C);
        var O = 0, K = function() {
        };
        return { s: K, n: function() {
          return O >= w.length ? { done: !0 } : { done: !1, value: w[O++] };
        }, e: function(_) {
          throw _;
        }, f: K };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var Y = !0, D = !1, B;
    return { s: function() {
      C = w[Symbol.iterator]();
    }, n: function() {
      var _ = C.next();
      return Y = _.done, _;
    }, e: function(_) {
      D = !0, B = _;
    }, f: function() {
      try {
        !Y && C.return != null && C.return();
      } finally {
        if (D) throw B;
      }
    } };
  }
  function y(w, I) {
    if (w) {
      if (typeof w == "string") return M(w, I);
      var C = Object.prototype.toString.call(w).slice(8, -1);
      if (C === "Object" && w.constructor && (C = w.constructor.name), C === "Map" || C === "Set") return Array.from(w);
      if (C === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(C)) return M(w, I);
    }
  }
  function M(w, I) {
    (I == null || I > w.length) && (I = w.length);
    for (var C = 0, O = new Array(I); C < I; C++)
      O[C] = w[C];
    return O;
  }
  var l = Ie(), X = Re(), F = He(), t = Oe(), b = new l("sanityCheck"), E = [T], i = [W, j, P, g], c = [k, N], o, h, p;
  Dn = function(w, I, C) {
    o = w, h = I, p = C;
    var O = U(E), K;
    try {
      for (O.s(); !(K = O.n()).done; ) {
        var Y = K.value;
        if (Y() === !1)
          return !1;
      }
    } catch (G) {
      O.e(G);
    } finally {
      O.f();
    }
    if (o instanceof F.IncomingRequest) {
      var D = U(i), B;
      try {
        for (D.s(); !(B = D.n()).done; ) {
          var d = B.value;
          if (d() === !1)
            return !1;
        }
      } catch (G) {
        D.e(G);
      } finally {
        D.f();
      }
    } else if (o instanceof F.IncomingResponse) {
      var _ = U(c), R;
      try {
        for (_.s(); !(R = _.n()).done; ) {
          var A = R.value;
          if (A() === !1)
            return !1;
        }
      } catch (G) {
        _.e(G);
      } finally {
        _.f();
      }
    }
    return !0;
  };
  function W() {
    if (o.s("to").uri.scheme !== "sip")
      return v(416), !1;
  }
  function j() {
    if (!o.to_tag && o.call_id.substr(0, 5) === h.configuration.jssip_id)
      return v(482), !1;
  }
  function P() {
    var w = t.str_utf8_length(o.body), I = o.getHeader("content-length");
    if (w < I)
      return v(400), !1;
  }
  function g() {
    var w = o.from_tag, I = o.call_id, C = o.cseq, O;
    if (!o.to_tag)
      if (o.method === X.INVITE) {
        if (h._transactions.ist[o.via_branch])
          return !1;
        for (var K in h._transactions.ist)
          if (Object.prototype.hasOwnProperty.call(h._transactions.ist, K) && (O = h._transactions.ist[K], O.request.from_tag === w && O.request.call_id === I && O.request.cseq === C))
            return v(482), !1;
      } else {
        if (h._transactions.nist[o.via_branch])
          return !1;
        for (var Y in h._transactions.nist)
          if (Object.prototype.hasOwnProperty.call(h._transactions.nist, Y) && (O = h._transactions.nist[Y], O.request.from_tag === w && O.request.call_id === I && O.request.cseq === C))
            return v(482), !1;
      }
  }
  function k() {
    if (o.getHeaders("via").length > 1)
      return b.debug("more than one Via header field present in the response, dropping the response"), !1;
  }
  function N() {
    var w = t.str_utf8_length(o.body), I = o.getHeader("content-length");
    if (w < I)
      return b.debug("message body length is lower than the value in Content-Length header field, dropping the response"), !1;
  }
  function T() {
    for (var w = ["from", "to", "call_id", "cseq", "via"], I = 0, C = w; I < C.length; I++) {
      var O = C[I];
      if (!o.hasHeader(O))
        return b.debug("missing mandatory header field : ".concat(O, ", dropping the response")), !1;
    }
  }
  function v(w) {
    var I = o.getHeaders("via"), C, O = "SIP/2.0 ".concat(w, " ").concat(X.REASON_PHRASE[w], `\r
`), K = U(I), Y;
    try {
      for (K.s(); !(Y = K.n()).done; ) {
        var D = Y.value;
        O += "Via: ".concat(D, `\r
`);
      }
    } catch (B) {
      K.e(B);
    } finally {
      K.f();
    }
    C = o.getHeader("To"), o.to_tag || (C += ";tag=".concat(t.newTag())), O += "To: ".concat(C, `\r
`), O += "From: ".concat(o.getHeader("From"), `\r
`), O += "Call-ID: ".concat(o.call_id, `\r
`), O += "CSeq: ".concat(o.cseq, " ").concat(o.method, `\r
`), O += `\r
`, p.send(O);
  }
  return Dn;
}
var Nt = {}, ci;
function Ul() {
  if (ci) return Nt;
  ci = 1;
  function U(c, o) {
    var h;
    if (typeof Symbol > "u" || c[Symbol.iterator] == null) {
      if (Array.isArray(c) || (h = y(c)) || o) {
        h && (c = h);
        var p = 0, W = function() {
        };
        return { s: W, n: function() {
          return p >= c.length ? { done: !0 } : { done: !1, value: c[p++] };
        }, e: function(N) {
          throw N;
        }, f: W };
      }
      throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
    }
    var j = !0, P = !1, g;
    return { s: function() {
      h = c[Symbol.iterator]();
    }, n: function() {
      var N = h.next();
      return j = N.done, N;
    }, e: function(N) {
      P = !0, g = N;
    }, f: function() {
      try {
        !j && h.return != null && h.return();
      } finally {
        if (P) throw g;
      }
    } };
  }
  function y(c, o) {
    if (c) {
      if (typeof c == "string") return M(c, o);
      var h = Object.prototype.toString.call(c).slice(8, -1);
      if (h === "Object" && c.constructor && (h = c.constructor.name), h === "Map" || h === "Set") return Array.from(c);
      if (h === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h)) return M(c, o);
    }
  }
  function M(c, o) {
    (o == null || o > c.length) && (o = c.length);
    for (var h = 0, p = new Array(o); h < o; h++)
      p[h] = c[h];
    return p;
  }
  var l = Oe(), X = Re(), F = Ue(), t = Ve(), b = Ti(), E = Ge();
  Nt.settings = {
    // SIP authentication.
    authorization_user: null,
    password: null,
    realm: null,
    ha1: null,
    authorization_jwt: null,
    // SIP account.
    display_name: null,
    uri: null,
    contact_uri: null,
    // SIP instance id (GRUU).
    instance_id: null,
    // Preloaded SIP Route header field.
    use_preloaded_route: !1,
    // Session parameters.
    session_timers: !0,
    session_timers_refresh_method: X.UPDATE,
    session_timers_force_refresher: !1,
    no_answer_timeout: 60,
    // Registration parameters.
    register: !0,
    register_expires: 600,
    registrar_server: null,
    // Connection options.
    sockets: null,
    connection_recovery_max_interval: X.CONNECTION_RECOVERY_MAX_INTERVAL,
    connection_recovery_min_interval: X.CONNECTION_RECOVERY_MIN_INTERVAL,
    // Global extra headers, to be added to every request and response
    extra_headers: null,
    /*
     * Host address.
     * Value to be set in Via sent_by and host part of Contact FQDN.
    */
    via_host: "".concat(l.createRandomToken(12), ".invalid")
  };
  var i = {
    mandatory: {
      sockets: function(o) {
        var h = [];
        if (b.isSocket(o))
          h.push({
            socket: o
          });
        else if (Array.isArray(o) && o.length) {
          var p = U(o), W;
          try {
            for (p.s(); !(W = p.n()).done; ) {
              var j = W.value;
              Object.prototype.hasOwnProperty.call(j, "socket") && b.isSocket(j.socket) ? h.push(j) : b.isSocket(j) && h.push({
                socket: j
              });
            }
          } catch (P) {
            p.e(P);
          } finally {
            p.f();
          }
        } else
          return;
        return h;
      },
      uri: function(o) {
        /^sip:/i.test(o) || (o = "".concat(X.SIP, ":").concat(o));
        var h = t.parse(o);
        if (h)
          return h.user ? h : void 0;
      }
    },
    optional: {
      authorization_user: function(o) {
        if (F.parse('"'.concat(o, '"'), "quoted_string") !== -1)
          return o;
      },
      authorization_jwt: function(o) {
        if (typeof o == "string")
          return o;
      },
      user_agent: function(o) {
        if (typeof o == "string")
          return o;
      },
      connection_recovery_max_interval: function(o) {
        if (l.isDecimal(o)) {
          var h = Number(o);
          if (h > 0)
            return h;
        }
      },
      connection_recovery_min_interval: function(o) {
        if (l.isDecimal(o)) {
          var h = Number(o);
          if (h > 0)
            return h;
        }
      },
      contact_uri: function(o) {
        if (typeof o == "string") {
          var h = F.parse(o, "SIP_URI");
          if (h !== -1)
            return h;
        }
      },
      display_name: function(o) {
        return o;
      },
      instance_id: function(o) {
        if (/^uuid:/i.test(o) && (o = o.substr(5)), F.parse(o, "uuid") !== -1)
          return o;
      },
      no_answer_timeout: function(o) {
        if (l.isDecimal(o)) {
          var h = Number(o);
          if (h > 0)
            return h;
        }
      },
      session_timers: function(o) {
        if (typeof o == "boolean")
          return o;
      },
      session_timers_refresh_method: function(o) {
        if (typeof o == "string" && (o = o.toUpperCase(), o === X.INVITE || o === X.UPDATE))
          return o;
      },
      session_timers_force_refresher: function(o) {
        if (typeof o == "boolean")
          return o;
      },
      password: function(o) {
        return String(o);
      },
      realm: function(o) {
        return String(o);
      },
      ha1: function(o) {
        return String(o);
      },
      register: function(o) {
        if (typeof o == "boolean")
          return o;
      },
      register_expires: function(o) {
        if (l.isDecimal(o)) {
          var h = Number(o);
          if (h > 0)
            return h;
        }
      },
      registrar_server: function(o) {
        /^sip:/i.test(o) || (o = "".concat(X.SIP, ":").concat(o));
        var h = t.parse(o);
        if (h)
          return h.user ? void 0 : h;
      },
      use_preloaded_route: function(o) {
        if (typeof o == "boolean")
          return o;
      },
      extra_headers: function(o) {
        var h = [];
        if (Array.isArray(o) && o.length) {
          var p = U(o), W;
          try {
            for (p.s(); !(W = p.n()).done; ) {
              var j = W.value;
              typeof j == "string" && h.push(j);
            }
          } catch (P) {
            p.e(P);
          } finally {
            p.f();
          }
        } else
          return;
        return h;
      }
    }
  };
  return Nt.load = function(c, o) {
    for (var h in i.mandatory)
      if (o.hasOwnProperty(h)) {
        var p = o[h], W = i.mandatory[h](p);
        if (W !== void 0)
          c[h] = W;
        else
          throw new E.ConfigurationError(h, p);
      } else
        throw new E.ConfigurationError(h);
    for (var j in i.optional)
      if (o.hasOwnProperty(j)) {
        var P = o[j];
        if (l.isEmpty(P))
          continue;
        var g = i.optional[j](P);
        if (g !== void 0)
          c[j] = g;
        else
          throw new E.ConfigurationError(j, P);
      }
  }, Nt;
}
var Pn, hi;
function Ml() {
  if (hi) return Pn;
  hi = 1;
  function U(A) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? U = function(V) {
      return typeof V;
    } : U = function(V) {
      return V && typeof Symbol == "function" && V.constructor === Symbol && V !== Symbol.prototype ? "symbol" : typeof V;
    }, U(A);
  }
  function y(A, G) {
    if (!(A instanceof G))
      throw new TypeError("Cannot call a class as a function");
  }
  function M(A, G) {
    for (var V = 0; V < G.length; V++) {
      var x = G[V];
      x.enumerable = x.enumerable || !1, x.configurable = !0, "value" in x && (x.writable = !0), Object.defineProperty(A, x.key, x);
    }
  }
  function l(A, G, V) {
    return G && M(A.prototype, G), V && M(A, V), A;
  }
  function X(A, G) {
    if (typeof G != "function" && G !== null)
      throw new TypeError("Super expression must either be null or a function");
    A.prototype = Object.create(G && G.prototype, { constructor: { value: A, writable: !0, configurable: !0 } }), G && F(A, G);
  }
  function F(A, G) {
    return F = Object.setPrototypeOf || function(x, u) {
      return x.__proto__ = u, x;
    }, F(A, G);
  }
  function t(A) {
    var G = i();
    return function() {
      var x = c(A), u;
      if (G) {
        var m = c(this).constructor;
        u = Reflect.construct(x, arguments, m);
      } else
        u = x.apply(this, arguments);
      return b(this, u);
    };
  }
  function b(A, G) {
    return G && (U(G) === "object" || typeof G == "function") ? G : E(A);
  }
  function E(A) {
    if (A === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return A;
  }
  function i() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function c(A) {
    return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(V) {
      return V.__proto__ || Object.getPrototypeOf(V);
    }, c(A);
  }
  var o = Be().EventEmitter, h = Ie(), p = Re(), W = Cl(), j = Ol(), P = Nl(), g = kl(), k = ct(), N = Dl(), T = Oe(), v = Ge(), w = Ve(), I = Pl(), C = He(), O = xl(), K = Ul(), Y = new h("UA"), D = {
    // UA status codes.
    STATUS_INIT: 0,
    STATUS_READY: 1,
    STATUS_USER_CLOSED: 2,
    STATUS_NOT_READY: 3,
    // UA error codes.
    CONFIGURATION_ERROR: 1,
    NETWORK_ERROR: 2
  };
  Pn = /* @__PURE__ */ function(A) {
    X(V, A);
    var G = t(V);
    l(V, null, [{
      key: "C",
      // Expose C object.
      get: function() {
        return D;
      }
    }]);
    function V(x) {
      var u;
      if (y(this, V), Y.debug("new() [configuration:%o]", x), u = G.call(this), u._cache = {
        credentials: {}
      }, u._configuration = Object.assign({}, K.settings), u._dynConfiguration = {}, u._dialogs = {}, u._applicants = {}, u._sessions = {}, u._transport = null, u._contact = null, u._status = D.STATUS_INIT, u._error = null, u._transactions = {
        nist: {},
        nict: {},
        ist: {},
        ict: {}
      }, u._data = {}, u._closeTimer = null, x === void 0)
        throw new TypeError("Not enough arguments");
      try {
        u._loadConfig(x);
      } catch (m) {
        throw u._status = D.STATUS_NOT_READY, u._error = D.CONFIGURATION_ERROR, m;
      }
      return u._registrator = new W(E(u)), u;
    }
    return l(V, [{
      key: "start",
      // =================
      //  High Level API
      // =================
      /**
       * Connect to the server if status = STATUS_INIT.
       * Resume UA after being closed.
       */
      value: function() {
        Y.debug("start()"), this._status === D.STATUS_INIT ? this._transport.connect() : this._status === D.STATUS_USER_CLOSED ? (Y.debug("restarting UA"), this._closeTimer !== null && (clearTimeout(this._closeTimer), this._closeTimer = null, this._transport.disconnect()), this._status = D.STATUS_INIT, this._transport.connect()) : this._status === D.STATUS_READY ? Y.debug("UA is in READY status, not restarted") : Y.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"), this._dynConfiguration.register = this._configuration.register;
      }
      /**
       * Register.
       */
    }, {
      key: "register",
      value: function() {
        Y.debug("register()"), this._dynConfiguration.register = !0, this._registrator.register();
      }
      /**
       * Unregister.
       */
    }, {
      key: "unregister",
      value: function(u) {
        Y.debug("unregister()"), this._dynConfiguration.register = !1, this._registrator.unregister(u);
      }
      /**
       * Get the Registrator instance.
       */
    }, {
      key: "registrator",
      value: function() {
        return this._registrator;
      }
      /**
       * Registration state.
       */
    }, {
      key: "isRegistered",
      value: function() {
        return this._registrator.registered;
      }
      /**
       * Connection state.
       */
    }, {
      key: "isConnected",
      value: function() {
        return this._transport.isConnected();
      }
      /**
       * Make an outgoing call.
       *
       * -param {String} target
       * -param {Object} [options]
       *
       * -throws {TypeError}
       *
       */
    }, {
      key: "call",
      value: function(u, m) {
        Y.debug("call()");
        var L = new j(this);
        return L.connect(u, m), L;
      }
      /**
       * Send a message.
       *
       * -param {String} target
       * -param {String} body
       * -param {Object} [options]
       *
       * -throws {TypeError}
       *
       */
    }, {
      key: "sendMessage",
      value: function(u, m, L) {
        Y.debug("sendMessage()");
        var q = new P(this);
        return q.send(u, m, L), q;
      }
      /**
       * Send a SIP OPTIONS.
       *
       * -param {String} target
       * -param {String} [body]
       * -param {Object} [options]
       *
       * -throws {TypeError}
       *
       */
    }, {
      key: "sendOptions",
      value: function(u, m, L) {
        Y.debug("sendOptions()");
        var q = new g(this);
        return q.send(u, m, L), q;
      }
      /**
       * Terminate ongoing sessions.
       */
    }, {
      key: "terminateSessions",
      value: function(u) {
        Y.debug("terminateSessions()");
        for (var m in this._sessions)
          this._sessions[m].isEnded() || this._sessions[m].terminate(u);
      }
      /**
       * Gracefully close.
       *
       */
    }, {
      key: "stop",
      value: function() {
        var u = this;
        if (Y.debug("stop()"), this._dynConfiguration = {}, this._status === D.STATUS_USER_CLOSED) {
          Y.debug("UA already closed");
          return;
        }
        this._registrator.close();
        var m = Object.keys(this._sessions).length;
        for (var L in this._sessions)
          if (Object.prototype.hasOwnProperty.call(this._sessions, L)) {
            Y.debug("closing session ".concat(L));
            try {
              this._sessions[L].terminate();
            } catch {
            }
          }
        for (var q in this._applicants)
          if (Object.prototype.hasOwnProperty.call(this._applicants, q)) try {
            this._applicants[q].close();
          } catch {
          }
        this._status = D.STATUS_USER_CLOSED;
        var $ = Object.keys(this._transactions.nict).length + Object.keys(this._transactions.nist).length + Object.keys(this._transactions.ict).length + Object.keys(this._transactions.ist).length;
        $ === 0 && m === 0 ? this._transport.disconnect() : this._closeTimer = setTimeout(function() {
          u._closeTimer = null, u._transport.disconnect();
        }, 2e3);
      }
      /**
       * Normalice a string into a valid SIP request URI
       * -param {String} target
       * -returns {JsSIP.URI|undefined}
       */
    }, {
      key: "normalizeTarget",
      value: function(u) {
        return T.normalizeTarget(u, this._configuration.hostport_params);
      }
      /**
       * Allow retrieving configuration and autogenerated fields in runtime.
       */
    }, {
      key: "get",
      value: function(u) {
        switch (u) {
          case "authorization_user":
            return this._configuration.authorization_user;
          case "realm":
            return this._configuration.realm;
          case "ha1":
            return this._configuration.ha1;
          case "authorization_jwt":
            return this._configuration.authorization_jwt;
          default:
            Y.warn('get() | cannot get "%s" parameter in runtime', u);
            return;
        }
      }
      /**
       * Allow configuration changes in runtime.
       * Returns true if the parameter could be set.
       */
    }, {
      key: "set",
      value: function(u, m) {
        switch (u) {
          case "authorization_user": {
            this._configuration.authorization_user = String(m);
            break;
          }
          case "password": {
            this._configuration.password = String(m);
            break;
          }
          case "realm": {
            this._configuration.realm = String(m);
            break;
          }
          case "ha1": {
            this._configuration.ha1 = String(m), this._configuration.password = null;
            break;
          }
          case "authorization_jwt": {
            this._configuration.authorization_jwt = String(m);
            break;
          }
          case "display_name": {
            this._configuration.display_name = m;
            break;
          }
          case "extra_headers": {
            this._configuration.extra_headers = m;
            break;
          }
          default:
            return Y.warn('set() | cannot set "%s" parameter in runtime', u), !1;
        }
        return !0;
      }
      // ==========================
      // Event Handlers.
      // ==========================
      /**
       * new Transaction
       */
    }, {
      key: "newTransaction",
      value: function(u) {
        this._transactions[u.type][u.id] = u, this.emit("newTransaction", {
          transaction: u
        });
      }
      /**
       * Transaction destroyed.
       */
    }, {
      key: "destroyTransaction",
      value: function(u) {
        delete this._transactions[u.type][u.id], this.emit("transactionDestroyed", {
          transaction: u
        });
      }
      /**
       * new Dialog
       */
    }, {
      key: "newDialog",
      value: function(u) {
        this._dialogs[u.id] = u;
      }
      /**
       * Dialog destroyed.
       */
    }, {
      key: "destroyDialog",
      value: function(u) {
        delete this._dialogs[u.id];
      }
      /**
       *  new Message
       */
    }, {
      key: "newMessage",
      value: function(u, m) {
        this._applicants[u] = u, this.emit("newMessage", m);
      }
      /**
       *  new Options
       */
    }, {
      key: "newOptions",
      value: function(u, m) {
        this._applicants[u] = u, this.emit("newOptions", m);
      }
      /**
       *  Message destroyed.
       */
    }, {
      key: "destroyMessage",
      value: function(u) {
        delete this._applicants[u];
      }
      /**
       * new RTCSession
       */
    }, {
      key: "newRTCSession",
      value: function(u, m) {
        this._sessions[u.id] = u, this.emit("newRTCSession", m);
      }
      /**
       * RTCSession destroyed.
       */
    }, {
      key: "destroyRTCSession",
      value: function(u) {
        delete this._sessions[u.id];
      }
      /**
       * Registered
       */
    }, {
      key: "registered",
      value: function(u) {
        this.emit("registered", u);
      }
      /**
       * Unregistered
       */
    }, {
      key: "unregistered",
      value: function(u) {
        this.emit("unregistered", u);
      }
      /**
       * Registration Failed
       */
    }, {
      key: "registrationFailed",
      value: function(u) {
        this.emit("registrationFailed", u);
      }
      // =========================
      // ReceiveRequest.
      // =========================
      /**
       * Request reception
       */
    }, {
      key: "receiveRequest",
      value: function(u) {
        var m = u.method;
        if (u.ruri.user !== this._configuration.uri.user && u.ruri.user !== this._contact.uri.user) {
          Y.debug("Request-URI does not point to us"), u.method !== p.ACK && u.reply_sl(404);
          return;
        }
        if (u.ruri.scheme === p.SIPS) {
          u.reply_sl(416);
          return;
        }
        if (!k.checkTransaction(this, u)) {
          if (m === p.INVITE ? new k.InviteServerTransaction(this, this._transport, u) : m !== p.ACK && m !== p.CANCEL && new k.NonInviteServerTransaction(this, this._transport, u), m === p.OPTIONS) {
            if (this.listeners("newOptions").length === 0) {
              u.reply(200);
              return;
            }
            var L = new g(this);
            L.init_incoming(u);
          } else if (m === p.MESSAGE) {
            if (this.listeners("newMessage").length === 0) {
              u.reply(405);
              return;
            }
            var q = new P(this);
            q.init_incoming(u);
          } else if (m === p.INVITE && !u.to_tag && this.listeners("newRTCSession").length === 0) {
            u.reply(405);
            return;
          }
          var $, z;
          if (u.to_tag)
            $ = this._findDialog(u.call_id, u.from_tag, u.to_tag), $ ? $.receiveRequest(u) : m === p.NOTIFY ? (z = this._findSession(u), z ? z.receiveRequest(u) : (Y.debug("received NOTIFY request for a non existent subscription"), u.reply(481, "Subscription does not exist"))) : m !== p.ACK && u.reply(481);
          else
            switch (m) {
              case p.INVITE:
                if (window.RTCPeerConnection)
                  if (u.hasHeader("replaces")) {
                    var ee = u.replaces;
                    $ = this._findDialog(ee.call_id, ee.from_tag, ee.to_tag), $ ? (z = $.owner, z.isEnded() ? u.reply(603) : z.receiveRequest(u)) : u.reply(481);
                  } else
                    z = new j(this), z.init_incoming(u);
                else
                  Y.warn("INVITE received but WebRTC is not supported"), u.reply(488);
                break;
              case p.BYE:
                u.reply(481);
                break;
              case p.CANCEL:
                z = this._findSession(u), z ? z.receiveRequest(u) : Y.debug("received CANCEL request for a non existent session");
                break;
              case p.ACK:
                break;
              case p.NOTIFY:
                this.emit("sipEvent", {
                  event: u.event,
                  request: u
                }), u.reply(200);
                break;
              default:
                u.reply(405);
                break;
            }
        }
      }
      // =================
      // Utils.
      // =================
      /**
       * Get the session to which the request belongs to, if any.
       */
    }, {
      key: "_findSession",
      value: function(u) {
        var m = u.call_id, L = u.from_tag, q = u.to_tag, $ = m + L, z = this._sessions[$], ee = m + q, Z = this._sessions[ee];
        return z || Z || null;
      }
      /**
       * Get the dialog to which the request belongs to, if any.
       */
    }, {
      key: "_findDialog",
      value: function(u, m, L) {
        var q = u + m + L, $ = this._dialogs[q];
        return $ || (q = u + L + m, $ = this._dialogs[q], $ || null);
      }
    }, {
      key: "_loadConfig",
      value: function(u) {
        try {
          K.load(this._configuration, u);
        } catch (ee) {
          throw ee;
        }
        this._configuration.display_name === 0 && (this._configuration.display_name = "0"), this._configuration.instance_id || (this._configuration.instance_id = T.newUUID()), this._configuration.jssip_id = T.createRandomToken(5);
        var m = this._configuration.uri.clone();
        m.user = null, this._configuration.hostport_params = m.toString().replace(/^sip:/i, "");
        try {
          this._transport = new N(this._configuration.sockets, {
            // Recovery options.
            max_interval: this._configuration.connection_recovery_max_interval,
            min_interval: this._configuration.connection_recovery_min_interval
          }), this._transport.onconnecting = B.bind(this), this._transport.onconnect = d.bind(this), this._transport.ondisconnect = _.bind(this), this._transport.ondata = R.bind(this);
        } catch (ee) {
          throw Y.warn(ee), new v.ConfigurationError("sockets", this._configuration.sockets);
        }
        if (delete this._configuration.sockets, this._configuration.authorization_user || (this._configuration.authorization_user = this._configuration.uri.user), !this._configuration.registrar_server) {
          var L = this._configuration.uri.clone();
          L.user = null, L.clearParams(), L.clearHeaders(), this._configuration.registrar_server = L;
        }
        this._configuration.no_answer_timeout *= 1e3, this._configuration.contact_uri ? this._configuration.via_host = this._configuration.contact_uri.host : this._configuration.contact_uri = new w("sip", T.createRandomToken(8), this._configuration.via_host, null, {
          transport: "ws"
        }), this._contact = {
          pub_gruu: null,
          temp_gruu: null,
          uri: this._configuration.contact_uri,
          toString: function() {
            var Z = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, re = Z.anonymous || null, se = Z.outbound || null, ne = "<";
            return re ? ne += this.temp_gruu || "sip:anonymous@anonymous.invalid;transport=ws" : ne += this.pub_gruu || this.uri.toString(), se && (re ? !this.temp_gruu : !this.pub_gruu) && (ne += ";ob"), ne += ">", ne;
          }
        };
        var q = ["authorization_user", "password", "realm", "ha1", "authorization_jwt", "display_name", "register", "extra_headers"];
        for (var $ in this._configuration)
          Object.prototype.hasOwnProperty.call(this._configuration, $) && (q.indexOf($) !== -1 ? Object.defineProperty(this._configuration, $, {
            writable: !0,
            configurable: !1
          }) : Object.defineProperty(this._configuration, $, {
            writable: !1,
            configurable: !1
          }));
        Y.debug("configuration parameters after validation:");
        for (var z in this._configuration)
          if (Object.prototype.hasOwnProperty.call(K.settings, z))
            switch (z) {
              case "uri":
              case "registrar_server":
                Y.debug("- ".concat(z, ": ").concat(this._configuration[z]));
                break;
              case "password":
              case "ha1":
              case "authorization_jwt":
                Y.debug("- ".concat(z, ": NOT SHOWN"));
                break;
              default:
                Y.debug("- ".concat(z, ": ").concat(JSON.stringify(this._configuration[z])));
            }
      }
    }, {
      key: "C",
      get: function() {
        return D;
      }
    }, {
      key: "status",
      get: function() {
        return this._status;
      }
    }, {
      key: "contact",
      get: function() {
        return this._contact;
      }
    }, {
      key: "configuration",
      get: function() {
        return this._configuration;
      }
    }, {
      key: "transport",
      get: function() {
        return this._transport;
      }
    }]), V;
  }(o);
  function B(A) {
    this.emit("connecting", A);
  }
  function d(A) {
    this._status !== D.STATUS_USER_CLOSED && (this._status = D.STATUS_READY, this._error = null, this.emit("connected", A), this._dynConfiguration.register && this._registrator.register());
  }
  function _(A) {
    for (var G = ["nict", "ict", "nist", "ist"], V = 0, x = G; V < x.length; V++) {
      var u = x[V];
      for (var m in this._transactions[u])
        Object.prototype.hasOwnProperty.call(this._transactions[u], m) && this._transactions[u][m].onTransportError();
    }
    this.emit("disconnected", A), this._registrator.onTransportClosed(), this._status !== D.STATUS_USER_CLOSED && (this._status = D.STATUS_NOT_READY, this._error = D.NETWORK_ERROR);
  }
  function R(A) {
    var G = A.transport, V = A.message;
    if (V = I.parseMessage(V, this), !!V && !(this._status === D.STATUS_USER_CLOSED && V instanceof C.IncomingRequest) && O(V, this, G)) {
      if (V instanceof C.IncomingRequest)
        V.transport = G, this.receiveRequest(V);
      else if (V instanceof C.IncomingResponse) {
        var x;
        switch (V.method) {
          case p.INVITE:
            x = this._transactions.ict[V.via_branch], x && x.receiveResponse(V);
            break;
          case p.ACK:
            break;
          default:
            x = this._transactions.nict[V.via_branch], x && x.receiveResponse(V);
            break;
        }
      }
    }
  }
  return Pn;
}
var xn, di;
function Ll() {
  if (di) return xn;
  di = 1;
  function U(t, b) {
    if (!(t instanceof b))
      throw new TypeError("Cannot call a class as a function");
  }
  function y(t, b) {
    for (var E = 0; E < b.length; E++) {
      var i = b[E];
      i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i);
    }
  }
  function M(t, b, E) {
    return b && y(t.prototype, b), t;
  }
  var l = Ie(), X = Ue(), F = new l("WebSocketInterface");
  return xn = /* @__PURE__ */ function() {
    function t(b) {
      U(this, t), F.debug('new() [url:"%s"]', b), this._url = b, this._sip_uri = null, this._via_transport = null, this._ws = null;
      var E = X.parse(b, "absoluteURI");
      if (E === -1)
        throw F.warn("invalid WebSocket URI: ".concat(b)), new TypeError("Invalid argument: ".concat(b));
      if (E.scheme !== "wss" && E.scheme !== "ws")
        throw F.warn("invalid WebSocket URI scheme: ".concat(E.scheme)), new TypeError("Invalid argument: ".concat(b));
      this._sip_uri = "sip:".concat(E.host).concat(E.port ? ":".concat(E.port) : "", ";transport=ws"), this._via_transport = E.scheme.toUpperCase();
    }
    return M(t, [{
      key: "connect",
      value: function() {
        if (F.debug("connect()"), this.isConnected()) {
          F.debug("WebSocket ".concat(this._url, " is already connected"));
          return;
        } else if (this.isConnecting()) {
          F.debug("WebSocket ".concat(this._url, " is connecting"));
          return;
        }
        this._ws && this.disconnect(), F.debug("connecting to WebSocket ".concat(this._url));
        try {
          this._ws = new WebSocket(this._url, "sip"), this._ws.binaryType = "arraybuffer", this._ws.onopen = this._onOpen.bind(this), this._ws.onclose = this._onClose.bind(this), this._ws.onmessage = this._onMessage.bind(this), this._ws.onerror = this._onError.bind(this);
        } catch (E) {
          this._onError(E);
        }
      }
    }, {
      key: "disconnect",
      value: function() {
        F.debug("disconnect()"), this._ws && (this._ws.onopen = function() {
        }, this._ws.onclose = function() {
        }, this._ws.onmessage = function() {
        }, this._ws.onerror = function() {
        }, this._ws.close(), this._ws = null);
      }
    }, {
      key: "send",
      value: function(E) {
        return F.debug("send()"), this.isConnected() ? (this._ws.send(E), !0) : (F.warn("unable to send message, WebSocket is not open"), !1);
      }
    }, {
      key: "isConnected",
      value: function() {
        return this._ws && this._ws.readyState === this._ws.OPEN;
      }
    }, {
      key: "isConnecting",
      value: function() {
        return this._ws && this._ws.readyState === this._ws.CONNECTING;
      }
      /**
       * WebSocket Event Handlers
       */
    }, {
      key: "_onOpen",
      value: function() {
        F.debug("WebSocket ".concat(this._url, " connected")), this.onconnect();
      }
    }, {
      key: "_onClose",
      value: function(E) {
        var i = E.wasClean, c = E.code, o = E.reason;
        F.debug("WebSocket ".concat(this._url, " closed")), i === !1 && F.debug("WebSocket abrupt disconnection"), this.ondisconnect(!i, c, o);
      }
    }, {
      key: "_onMessage",
      value: function(E) {
        var i = E.data;
        F.debug("received WebSocket message"), this.ondata(i);
      }
    }, {
      key: "_onError",
      value: function(E) {
        F.warn("WebSocket ".concat(this._url, " error: "), E);
      }
    }, {
      key: "via_transport",
      get: function() {
        return this._via_transport;
      },
      set: function(E) {
        this._via_transport = E.toUpperCase();
      }
    }, {
      key: "sip_uri",
      get: function() {
        return this._sip_uri;
      }
    }, {
      key: "url",
      get: function() {
        return this._url;
      }
    }]), t;
  }(), xn;
}
var Un, _i;
function Fl() {
  if (_i) return Un;
  _i = 1;
  var U = mi, y = Re(), M = Ge(), l = Oe(), X = Ml(), F = Ve(), t = Bn(), b = Ue(), E = Ll(), i = Fn()("JsSIP");
  return i("version %s", U.version), Un = {
    C: y,
    Exceptions: M,
    Utils: l,
    UA: X,
    URI: F,
    NameAddrHeader: t,
    WebSocketInterface: E,
    Grammar: b,
    // Expose the debug module.
    debug: Fn(),
    get name() {
      return U.title;
    },
    get version() {
      return U.version;
    }
  }, Un;
}
var Hl = Fl();
const Mn = /* @__PURE__ */ _l(Hl);
function ql(U) {
  return { all: U = U || /* @__PURE__ */ new Map(), on: function(y, M) {
    var l = U.get(y);
    l ? l.push(M) : U.set(y, [M]);
  }, off: function(y, M) {
    var l = U.get(y);
    l && (M ? l.splice(l.indexOf(M) >>> 0, 1) : U.set(y, []));
  }, emit: function(y, M) {
    var l = U.get(y);
    l && l.slice().map(function(X) {
      X(M);
    }), (l = U.get("*")) && l.slice().map(function(X) {
      X(y, M);
    });
  } };
}
function jl({ sipName: U, serverIp: y }) {
  return `sip:${U}@${y}`;
}
function Gl({ sipName: U, serverIp: y }) {
  return `sip:${U}@${y};transport=wss;ob`;
}
function Vl({ wssIp: U }) {
  return `${U}`;
}
const Bl = "1.0.0", Wl = {
  /* 这些后续由后台配置 */
  wssIp: "",
  serverIp: "",
  sipIp: "",
  password: "",
  sipName: "",
  // 用户ID
  /* JsSIP.UA 配置 */
  register: !0,
  // 自动注册
  /** 显示名称 */
  display_name: ""
}, pi = {
  deviceId: "default",
  echoCancellation: !0,
  // 回声消除
  noiseSuppression: !0,
  // 去噪
  sampleRate: 48e3,
  // 48kHz
  sampleSize: 16,
  // 16位
  channelCount: 2,
  // 立体声
  autoGainControl: !0
}, Kl = {
  deviceId: "default",
  width: { max: 1920 },
  // 最大宽度 1920 像素
  height: { max: 1080 },
  // 最大高度 1080 像素
  frameRate: { max: 60, min: 15 },
  // 最大帧率 60 帧/秒
  aspectRatio: { ideal: 16 / 9 }
  // 理想宽高比 16:9
}, xe = class xe extends Error {
  constructor(y, M) {
    const l = y || 999, X = xe.ErrorCodeDict[l], F = M || `[Error] code: ${l}, message: ${X || "未知错误"}`;
    super(F), this.name = "SIPSDKError", this.code = l;
  }
};
tn(xe, "ErrorCode", {
  mic: 101,
  camera: 102,
  network: 103,
  params: 104,
  unknown: 999
}), tn(xe, "ErrorCodeDict", {
  [xe.ErrorCode.mic]: "麦克风未授权",
  [xe.ErrorCode.camera]: "摄像头未授权",
  [xe.ErrorCode.params]: "参数错误",
  [xe.ErrorCode.network]: "网络异常",
  [xe.ErrorCode.unknown]: "未知错误"
});
let Ne = xe;
const zl = (U) => jl(U), Yl = (U) => Gl(U), $l = (U) => Vl(U), Ln = () => {
  const U = document.createElement("audio");
  return U.controls = !1, U.style.display = "none", U;
};
var $e, be, Xe, oe, Si, Hn, ze, Fe, Ci, Ei, Ai, qn, bi, Ri, wi, jn, ft, kt, Gn, Vn;
const Ye = class Ye {
  constructor() {
    ot(this, oe);
    /** eventbus对象 */
    ot(this, be);
    ot(this, Xe);
    if (Ce(Ye, $e))
      return Ce(Ye, $e);
    ut(Ye, $e, this), ut(this, be, ql()), this.version = Bl, this.ua = null, this.currentSession = null, this.callType = "audio", this.originator = null, this.localNumber = null, this.remoteNumber = null, this.localAudio = null, this.localVideo = null, this.remoteVideo = null, this.incomingRingtone = null, this.outgoingRingtone = null, this.localAudioStream = null, this.localVideoStream = null, this.desktopMediaStream = null, de(this, oe, Si).call(this);
  }
  /** 检查麦克风 */
  async checkMic() {
    try {
      (await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((M) => M.stop());
    } catch (y) {
      throw new Ne(Ne.ErrorCode.mic, y);
    }
  }
  /** 检查摄像头 */
  async checkCamera() {
    try {
      (await navigator.mediaDevices.getUserMedia({ video: !0 })).getTracks().forEach((M) => M.stop());
    } catch (y) {
      throw new Ne(Ne.ErrorCode.camera, y);
    }
  }
  /** 设置视频元素 */
  setVideoDom(y) {
    if (!y || !y.localVideo && !y.remoteVideo) throw Ne(Ne.ErrorCode.params);
    const { localVideo: M, remoteVideo: l } = y;
    this.localVideo = typeof M == "string" ? document.querySelector(M) : M, this.remoteVideo = typeof l == "string" ? document.querySelector(l) : l;
  }
  /** 设置铃声 */
  setRingtone({ incoming: y, outgoing: M }) {
    if (!y || !M) throw Ne(Ne.ErrorCode.params);
    this.incomingRingtone.src = y, this.outgoingRingtone.src = M;
  }
  /** TODO 初始化 SDK，需确认传入还是后端给值 */
  async init(y) {
    this.ua && this.destroy(), Mn.debug.disable("JsSIP:*"), await Promise.all([this.checkMic(), this.checkCamera()]);
    const M = {
      ...Wl,
      ...y
    };
    this.config = M, this.localNumber = M.sipName;
    const l = new Mn.WebSocketInterface($l(M));
    this.ua = new Mn.UA({
      sockets: [l],
      uri: zl(M),
      contact_uri: Yl(M),
      password: M.password,
      register: M.register,
      register_expires: 3600,
      display_name: M.display_name || M.sipName
    }), de(this, oe, Ai).call(this), this.ua.start();
  }
  /** 发起呼叫 */
  async call(y, M = "audio", l) {
    if (this.ua) {
      if (this.remoteNumber = y, this.callType = M, M !== "video" && M !== "audio")
        throw new Ne(Ne.ErrorCode.params);
      let X = null;
      M === "video" ? X = await de(this, oe, ze).call(this) : X = await de(this, oe, Hn).call(this), this.currentSession = this.ua.call(String(y), {
        mediaConstraints: { audio: !0, video: M === "video" },
        sessionTimersExpires: 1800,
        mediaStream: X,
        ...l
      });
    }
  }
  /** 接听 */
  async answerCall() {
    if (this.currentSession) {
      let y = null;
      this.callType === "video" ? y = await de(this, oe, ze).call(this) : y = await de(this, oe, Hn).call(this), this.currentSession.answer({
        mediaConstraints: { audio: !0, video: this.callType === "video" },
        sessionTimersExpires: 1800,
        mediaStream: y
      });
    }
  }
  /** 切换为语音，视频模式下 */
  async switchToAudio() {
    if (this.callType !== "video") return;
    const y = await de(this, oe, ze).call(this);
    y == null || y.getVideoTracks().forEach((M) => {
      M.enabled = !1;
    });
  }
  /** 切换为视频，视频模式下 */
  async switchToVideo() {
    if (this.callType !== "video") return;
    const y = await de(this, oe, ze).call(this);
    y == null || y.getVideoTracks().forEach((M) => {
      M.enabled = !0;
    });
  }
  /** 挂断 */
  hangup() {
    this.currentSession && this.currentSession.terminate();
  }
  /** 静音 */
  mute() {
    this.currentSession && (this.currentSession.mute({ audio: !0, video: !1 }), Ce(this, be).emit("muted"));
  }
  /** 取消静音 */
  unmute() {
    this.currentSession && (this.currentSession.unmute({ audio: !0, video: !1 }), Ce(this, be).emit("unmuted"));
  }
  /** 保持 */
  hold() {
    this.currentSession && (this.currentSession.hold({ useUpdate: !1 }), Ce(this, be).emit("hold"));
  }
  /** 取消保持 */
  unhold() {
    this.currentSession && (this.currentSession.unhold({ useUpdate: !1 }), Ce(this, be).emit("unhold"));
  }
  /** TODO 转接，可能是调接口 */
  async transfer(y) {
  }
  /** 发送DTMF指令 */
  sendDTMF(y) {
    var M;
    (M = this.currentSession) == null || M.sendDTMF(y);
  }
  /** 开始屏幕共享 */
  async desktopSharing() {
    if (!this.currentSession) return;
    let y = this.currentSession.connection;
    const M = await navigator.mediaDevices.getDisplayMedia({ video: !0 });
    this.desktopMediaStream = M;
    const l = M.getVideoTracks()[0];
    y.getSenders().forEach((X) => {
      X.track.kind === "video" && X.replaceTrack(l);
    }), this.localVideo.srcObject = M, Ce(this, be).emit("desktopSharing"), l.addEventListener("ended", (X) => {
      de(this, oe, jn).call(this);
    });
  }
  /** 结束屏幕共享 */
  async endDesktopSharing() {
    this.desktopMediaStream && (de(this, oe, ft).call(this, this.desktopMediaStream), this.desktopMediaStream = null, de(this, oe, jn).call(this));
  }
  register() {
    var y;
    (y = this.ua) == null || y.register();
  }
  unregister() {
    var y;
    (y = this.ua) == null || y.unregister();
  }
  /** 连接服务，如果ua配置中register为true时，自动注册 */
  start() {
    var y;
    (y = this.ua) == null || y.start();
  }
  /** 断开连接，不会取消注册 */
  stop() {
    var y;
    (y = this.ua) == null || y.stop();
  }
  /** 销毁 */
  destroy() {
    var y, M;
    de(this, oe, Gn).call(this), this.currentSession = null, (y = this.ua) == null || y.unregister(), (M = this.ua) == null || M.stop(), this.ua = null, ut(Ye, $e, null);
  }
  on(y, M) {
    Ce(this, be).on(y, M);
  }
  off(y, M) {
    Ce(this, be).off(y, M);
  }
};
$e = new WeakMap(), be = new WeakMap(), Xe = new WeakMap(), oe = new WeakSet(), /** 初始化音频dom */
Si = function() {
  if (Ce(this, Xe)) return;
  ut(this, Xe, "_sip_" + Math.random().toString(36).substring(2, 10)), this.localAudio = Ln(), this.incomingRingtone = Ln(), this.outgoingRingtone = Ln();
  const y = document.createElement("div");
  y.id = Ce(this, Xe), y.style.cssText = "width: 0; height: 0", y.appendChild(this.localAudio), y.appendChild(this.incomingRingtone), y.appendChild(this.outgoingRingtone), document.body.appendChild(y);
}, Hn = async function() {
  return this.localAudioStream || (this.localAudioStream = await navigator.mediaDevices.getUserMedia({
    audio: pi
  })), this.localAudioStream;
}, ze = async function() {
  return this.localVideoStream || (this.localVideoStream = await navigator.mediaDevices.getUserMedia({
    audio: pi,
    video: Kl
  })), this.localVideoStream;
}, /** 切换音频播放状态 */
Fe = function(y, M) {
  M ? y != null && y.paused && (y == null || y.play()) : !(y != null && y.paused) && (y.srcObject || y.src) && (y == null || y.pause());
}, /** 注册相关事件 */
Ci = function() {
  this.ua.on("registered", (y) => {
    Ce(this, be).emit("registered", y);
  }), this.ua.on("unregistered", (y) => {
    Ce(this, be).emit("unregistered", y);
  }), this.ua.on("registrationFailed", (y) => {
    Ce(this, be).emit("registrationFailed", y);
  }), this.ua.on("registrationExpiring", (y) => {
    Ce(this, be).emit("registrationExpiring", y);
  });
}, /** 会话相关事件 */
Ei = function(y) {
  const { originator: M, request: l, session: X } = y;
  this.currentSession = X, this.originator = M, [
    "peerconnection",
    "connecting",
    "sending",
    "progress",
    "accepted",
    "confirmed",
    "ended",
    "failed",
    "newDTMF",
    "newInfo",
    "hold",
    "unhold",
    "muted",
    "unmuted",
    "reinvite",
    "update",
    "refer",
    "replaces",
    "sdp",
    "icecandidate",
    "getusermediafailed",
    "peerconnection:createofferfailed",
    "peerconnection:createanswerfailed",
    "peerconnection:setlocaldescriptionfailed",
    "peerconnection:setremotedescriptionfailed"
  ].forEach((F) => {
    this.currentSession.on(F, (t) => {
    });
  }), this.currentSession.on("connecting", (F) => {
    M == "local" && this.currentSession.connection.addEventListener("track", (t) => {
      de(this, oe, qn).call(this, t.track, t.streams[0]);
    });
  }), this.currentSession.on("peerconnection", (F) => {
    M == "remote" && this.currentSession.connection.addEventListener("track", (t) => {
      de(this, oe, qn).call(this, t.track, t.streams[0]);
    });
  }), this.currentSession.on("progress", (F) => {
    var t;
    this.callType = (t = l.body) != null && t.includes("m=video") ? "video" : "audio", M === "remote" ? (this.remoteNumber = l.from.uri.user, de(this, oe, Fe).call(this, this.incomingRingtone, !0)) : de(this, oe, Fe).call(this, this.outgoingRingtone, !0), Ce(this, be).emit("ringing", {
      session: this.currentSession,
      callType: this.callType,
      originator: this.originator,
      remoteNumber: this.remoteNumber,
      localNumber: this.localNumber
    });
  }), this.currentSession.on("accepted", (F) => {
    var t;
    this.callType = (t = l.body) != null && t.includes("m=video") ? "video" : "audio", M === "remote" ? (this.remoteNumber = l.from.uri.user, de(this, oe, Fe).call(this, this.incomingRingtone, !1)) : de(this, oe, Fe).call(this, this.outgoingRingtone, !1), Ce(this, be).emit("answer", {
      session: this.currentSession,
      callType: this.callType,
      originator: this.originator,
      remoteNumber: this.remoteNumber,
      localNumber: this.localNumber
    });
  }), this.currentSession.on("confirmed", (F) => {
    this.callType === "audio" ? de(this, oe, Ri).call(this) : (de(this, oe, bi).call(this), de(this, oe, wi).call(this));
  }), this.currentSession.on("ended", (F) => {
    de(this, oe, Vn).call(this), M === "remote" ? de(this, oe, Fe).call(this, this.incomingRingtone, !1) : de(this, oe, Fe).call(this, this.outgoingRingtone, !1), Ce(this, be).emit("hangup");
  }), this.currentSession.on("failed", (F) => {
    de(this, oe, Vn).call(this), M === "remote" ? de(this, oe, Fe).call(this, this.incomingRingtone, !1) : de(this, oe, Fe).call(this, this.outgoingRingtone, !1), Ce(this, be).emit("hangup");
  });
}, Ai = function() {
  de(this, oe, Ci).call(this), this.ua.on("newRTCSession", (y) => de(this, oe, Ei).call(this, y));
}, /** 轨道处理，主要用于保持后恢复 */
qn = function(y, M) {
  y.kind === "audio" && (this.localAudio.srcObject = M, this.localAudio.play());
}, bi = async function() {
  const y = await de(this, oe, ze).call(this);
  y && (this.localVideo.srcObject = y, this.localVideo.muted = !0, this.localVideo.play());
}, /** 播放远程音频 */
Ri = function() {
  const { connection: y } = this.currentSession;
  !y || !y.getRemoteStreams().length || (this.localAudio.srcObject = y.getRemoteStreams()[0], this.localAudio.play());
}, /** 播放远程视频 */
wi = function() {
  const { connection: y } = this.currentSession;
  !y || !y.getRemoteStreams().length || (this.remoteVideo.srcObject = y.getRemoteStreams()[0], this.remoteVideo.play());
}, jn = async function() {
  if (!this.currentSession) return;
  let y = this.currentSession.connection;
  const M = await de(this, oe, ze).call(this);
  this.localVideo.srcObject = M, this.localVideoStream = M, y.getSenders().forEach((l) => {
    l.track && l.track.kind === "video" && l.replaceTrack(M.getVideoTracks()[0]);
  }), Ce(this, be).emit("endDesktopSharing");
}, /** 清除流 */
ft = function(y) {
  y && y.getTracks().forEach((M) => M.stop());
}, /** 清除媒体 */
kt = function(y) {
  y && (y.pause(), y.srcObject && de(this, oe, ft).call(this, y.srcObject), y.srcObject = null);
}, /** 清除所有媒体流 */
Gn = function() {
  de(this, oe, kt).call(this, this.localAudio), de(this, oe, kt).call(this, this.localVideo), de(this, oe, kt).call(this, this.remoteVideo), de(this, oe, ft).call(this, this.localAudioStream), de(this, oe, ft).call(this, this.localVideoStream), this.localAudioStream = null, this.localVideoStream = null;
}, Vn = function() {
  de(this, oe, Gn).call(this), this.currentSession = null, this.callType = "audio", this.remoteNumber = null;
}, /** 单例实例 */
ot(Ye, $e);
let vi = Ye;
export {
  vi as default
};
